Total Complexity | 5 |
Complexity/F | 1 |
Lines of Code | 81 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | import expect from 'expect'; |
||
2 | import { fromJS } from 'immutable'; |
||
3 | |||
4 | import { |
||
5 | generateLastUpdate, |
||
6 | getLastUpdate, |
||
7 | resetLastUpdate |
||
8 | } from './../../src/util/lastUpdate'; |
||
9 | |||
10 | describe('LastUpdate utility', () => { |
||
11 | |||
12 | it('Should generateLastUpdate with a incrementing number', () => { |
||
13 | const first = generateLastUpdate(); |
||
14 | const second = generateLastUpdate(); |
||
15 | |||
16 | expect( |
||
17 | first |
||
18 | ).toBeA('number'); |
||
19 | |||
20 | expect( |
||
21 | second |
||
22 | ).toBeA('number'); |
||
23 | |||
24 | expect( |
||
25 | first < second |
||
26 | ).toBe(true); |
||
27 | }); |
||
28 | |||
29 | it('Should resetLastUdate where next generate will return 1', () => { |
||
30 | resetLastUpdate(); |
||
31 | |||
32 | expect( |
||
33 | generateLastUpdate() |
||
34 | ).toBe(1); |
||
35 | |||
36 | expect( |
||
37 | generateLastUpdate() |
||
38 | ).toBe(2); |
||
39 | |||
40 | resetLastUpdate(); |
||
41 | |||
42 | expect( |
||
43 | generateLastUpdate() |
||
44 | ).toBe(1); |
||
45 | |||
46 | expect( |
||
47 | generateLastUpdate() |
||
48 | ).toBe(2); |
||
49 | }); |
||
50 | |||
51 | it('Should getLastupdate and provide a map of reducers lastUpdate', () => { |
||
52 | const store = { |
||
53 | getState: () => ({ |
||
54 | bulkaction: fromJS({ 'test-grid-1': { lastUpdate: 1 } }), |
||
55 | dataSource: fromJS({ 'test-grid-1': { lastUpdate: 2 } }), |
||
56 | editor: fromJS({ 'test-grid-1': { lastUpdate: 3 } }), |
||
57 | errorhandler: fromJS({ 'test-grid-1': { lastUpdate: 4 } }), |
||
58 | grid: fromJS({ 'test-grid-1': { lastUpdate: 6 } }), |
||
59 | loader: fromJS({ 'test-grid-1': { lastUpdate: 7 } }), |
||
60 | menu: fromJS({ 'test-grid-1': { lastUpdate: 8 } }), |
||
61 | pager: fromJS({ 'test-grid-1': { lastUpdate: 9 } }), |
||
62 | selection: fromJS({ 'test-grid-1': { lastUpdate: 10 } }) |
||
63 | }) |
||
64 | }; |
||
65 | |||
66 | expect( |
||
67 | getLastUpdate(store, 'test-grid-1') |
||
68 | ).toEqual({ |
||
69 | bulkaction: 1, |
||
70 | dataSource: 2, |
||
71 | editor: 3, |
||
72 | errorhandler: 4, |
||
73 | grid: 6, |
||
74 | loader: 7, |
||
75 | menu: 8, |
||
76 | pager: 9, |
||
77 | selection: 10 |
||
78 | }); |
||
79 | }); |
||
80 | |||
81 | }); |
||
82 |