Passed
Push — master ( 6c3603...8c31e5 )
by Pieter Epeüs
01:48 queued 12s
created

src/__tests__/create-all.spec.js   A

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 24
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
mnd 0
bc 0
fnc 3
dl 0
loc 24
rs 10
bpm 0
cpm 1
noi 5
c 0
b 0
f 0
1
import { expect, describe, it } from '@jest/globals';
2
import Obj from '../objects.js';
3
4
const schema = {
5
    sku: String
0 ignored issues
show
introduced by
Insert ,
Loading history...
6
}
0 ignored issues
show
introduced by
Insert ;
Loading history...
7
const ObjectWithSchema = Obj({ schema });
8
9
describe('Test createAll', () => {
10
    it('It should create an object for all items', () => {
11
        const data = [
0 ignored issues
show
introduced by
Replace ... with {·sku:·'123'·},·{·sku:·'124'·}];
Loading history...
12
            { sku: '123' },
13
            { sku: '124' },
14
        ]
15
        const result = ObjectWithSchema.createAll(data);
16
        expect(result).toEqual(data);
17
18
        const keys = result.map(item => item.keys());
0 ignored issues
show
introduced by
Replace item with (item)
Loading history...
19
        expect(keys).toEqual([
0 ignored issues
show
introduced by
Replace ...ku']⏎········ with ['sku'],·['sku']
Loading history...
20
            ['sku'],
21
            ['sku']
22
        ]);
23
    });
24
});
25