| Total Complexity | 9 |
| Complexity/F | 1 |
| Lines of Code | 56 |
| Function Count | 9 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { expect, describe, it } from '@jest/globals'; |
||
| 2 | import Obj from '../objects'; |
||
| 3 | |||
| 4 | const testSchema = { |
||
| 5 | a: Number, |
||
| 6 | b: Number, |
||
| 7 | }; |
||
| 8 | |||
| 9 | // deepcode ignore ExpectsArray: False error, it should allow an object |
||
| 10 | const Test = Obj({ schema: testSchema }); |
||
| 11 | |||
| 12 | describe('Test objects.js every', () => { |
||
| 13 | it('It should return true because some value is 3', () => { |
||
| 14 | const input = { |
||
| 15 | a: 1, |
||
| 16 | b: 2, |
||
| 17 | c: 3, |
||
| 18 | }; |
||
| 19 | |||
| 20 | expect(Test.create(input).some((x) => x === 3)).toBeTruthy(); |
||
| 21 | }); |
||
| 22 | |||
| 23 | it('It should return false because the is no value 4', () => { |
||
| 24 | const input = { |
||
| 25 | a: 1, |
||
| 26 | b: 2, |
||
| 27 | c: 3, |
||
| 28 | }; |
||
| 29 | |||
| 30 | expect(Test.create(input).some((x) => x === 3)).toBeTruthy(); |
||
| 31 | }); |
||
| 32 | |||
| 33 | it('It should return true because some flat values are 2', () => { |
||
| 34 | const input = { |
||
| 35 | a: 1, |
||
| 36 | b: 2, |
||
| 37 | c: [1, 2], |
||
| 38 | d: { e: 1, f: 2 }, |
||
| 39 | g: { h: { i: 1 } }, |
||
| 40 | }; |
||
| 41 | |||
| 42 | expect(Test.create(input).flatSome((x) => x === 2)).toBeTruthy(); |
||
| 43 | }); |
||
| 44 | |||
| 45 | it('It should return false because not some flat values are 3', () => { |
||
| 46 | const input = { |
||
| 47 | a: 1, |
||
| 48 | b: 2, |
||
| 49 | c: [1, 2], |
||
| 50 | d: { e: 1, f: 2 }, |
||
| 51 | g: { h: { i: 1 } }, |
||
| 52 | }; |
||
| 53 | |||
| 54 | expect(Test.create(input).flatSome((x) => x === 3)).toBeFalsy(); |
||
| 55 | }); |
||
| 56 | }); |
||
| 57 |