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