forked from regentmarkets-repo-archive/binary-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayToObject-test.js
More file actions
45 lines (43 loc) · 1.08 KB
/
Copy patharrayToObject-test.js
File metadata and controls
45 lines (43 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import arrayToObject from '../arrayToObject';
describe('arrayToObject', () => {
it('should convert arrays of objects into object with arrays of value', () => {
const arr = [
{
text: 'zero',
value: 0,
},
{
text: 'one',
value: 1,
},
{
text: 'zero',
value: 0,
},
{
text: 'one',
value: 1,
},
{
text: 'two',
value: 2,
},
{
text: 'two',
value: 2,
},
{
text: 'three',
value: 3,
},
{
text: 'four',
value: 4,
},
];
const converted = arrayToObject(arr);
expect(Object.keys(converted).length).toEqual(2);
expect(converted.text.length).toEqual(8);
expect(converted.value).toEqual([0, 1, 0, 1, 2, 2, 3, 4]);
});
});