| Total Complexity | 9 |
| Complexity/F | 1 |
| Lines of Code | 55 |
| 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 | const Test = Obj({ schema: testSchema }); |
||
| 10 | |||
| 11 | describe('Test objects.js every', () => { |
||
| 12 | it('It should return true because some value is 3', () => { |
||
| 13 | const input = { |
||
| 14 | a: 1, |
||
| 15 | b: 2, |
||
| 16 | c: 3, |
||
| 17 | }; |
||
| 18 | |||
| 19 | expect(Test.create(input).some((x) => x === 3)).toBeTruthy(); |
||
| 20 | }); |
||
| 21 | |||
| 22 | it('It should return false because the is no value 4', () => { |
||
| 23 | const input = { |
||
| 24 | a: 1, |
||
| 25 | b: 2, |
||
| 26 | c: 3, |
||
| 27 | }; |
||
| 28 | |||
| 29 | expect(Test.create(input).some((x) => x === 3)).toBeTruthy(); |
||
| 30 | }); |
||
| 31 | |||
| 32 | it('It should return true because some flat values are 2', () => { |
||
| 33 | const input = { |
||
| 34 | a: 1, |
||
| 35 | b: 2, |
||
| 36 | c: [1, 2], |
||
| 37 | d: { e: 1, f: 2 }, |
||
| 38 | g: { h: { i: 1 } }, |
||
| 39 | }; |
||
| 40 | |||
| 41 | expect(Test.create(input).flatSome((x) => x === 2)).toBeTruthy(); |
||
| 42 | }); |
||
| 43 | |||
| 44 | it('It should return false because not some flat values are 3', () => { |
||
| 45 | const input = { |
||
| 46 | a: 1, |
||
| 47 | b: 2, |
||
| 48 | c: [1, 2], |
||
| 49 | d: { e: 1, f: 2 }, |
||
| 50 | g: { h: { i: 1 } }, |
||
| 51 | }; |
||
| 52 | |||
| 53 | expect(Test.create(input).flatSome((x) => x === 3)).toBeFalsy(); |
||
| 54 | }); |
||
| 55 | }); |
||
| 56 |