-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfindDeepMatchIndex.js
51 lines (49 loc) · 1.32 KB
/
findDeepMatchIndex.js
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
46
47
48
49
50
51
import expect from 'expect';
import findDeepMatchIndex from '../../../src/asserts/utils/findDeepMatchIndex';
describe('assertion utils', () => {
describe('getDispatchedActions', () => {
it('should be function', () => { expect(findDeepMatchIndex).toBeA('function'); });
it('should find a object whose properties match', () => {
const list = [
{
type: 'a',
payload: [0, 1, 2]
},
{
type: 'b',
payload: [0, 1, 2]
},
{
type: 'c',
payload: [0, 1, 2]
}
];
const item = {
type: 'b',
payload: [0, 1, 2]
};
expect(findDeepMatchIndex(list, item)).toBe(1);
});
it('should not find a object whose properties match in type but not in value', () => {
const list = [
{
type: 'a',
payload: [0, 1, 2]
},
{
type: 'b',
payload: [0, 1, 2]
},
{
type: 'c',
payload: [0, 1, 2]
}
];
const item = {
type: 'b',
payload: []
};
expect(findDeepMatchIndex(list, item)).toBe(-1);
});
});
});