Passed
Pull Request — master (#140)
by Pieter Epeüs
03:26 queued 11s
created

src/__tests__/some-object.spec.js   A

Complexity

Total Complexity 9
Complexity/F 1

Size

Lines of Code 55
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 35
mnd 0
bc 0
fnc 9
dl 0
loc 55
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 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