Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 37 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { expect, describe, it } from '@jest/globals'; |
||
2 | import Obj from '../objects.js'; |
||
3 | |||
4 | describe('Object test', () => { |
||
5 | const CountrySchema = { |
||
6 | name: String, |
||
7 | code: String, |
||
8 | active: Boolean, |
||
9 | }; |
||
10 | |||
11 | const addressSchema = { |
||
12 | street: String, |
||
13 | number: 'number', |
||
14 | postalCode: String, |
||
15 | city: String, |
||
16 | country: CountrySchema, |
||
17 | }; |
||
18 | |||
19 | // deepcode ignore ExpectsArray: False error, it should allow an object |
||
20 | const Address = Obj({ schema: addressSchema }); |
||
21 | |||
22 | it('It should throw an exception', () => { |
||
23 | expect(() => { |
||
24 | Address.create({ |
||
25 | street: 'Abc', |
||
26 | number: 42, |
||
27 | postalCode: '1234AB', |
||
28 | city: 'Example', |
||
29 | country: { |
||
30 | name: 'Germany', |
||
31 | code: 'DE', |
||
32 | active: 'true', |
||
33 | }, |
||
34 | }); |
||
35 | }).toThrowError('The field country.active should be a Boolean'); |
||
36 | }); |
||
37 | }); |
||
38 |