Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 99 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | import expect from 'expect'; |
||
2 | |||
3 | import { |
||
4 | SET_COLUMNS |
||
5 | } from './../../../src/constants/ActionTypes'; |
||
6 | |||
7 | import { |
||
8 | reorderColumn |
||
9 | } from './../../../src/actions/core/ColumnManager'; |
||
10 | |||
11 | describe('The reorderColumn gridAction', () => { |
||
12 | |||
13 | it('Should reorder columns correctly', () => { |
||
14 | const action = { |
||
15 | draggedIndex: 0, |
||
16 | droppedIndex: 1, |
||
17 | columns: [ |
||
18 | { |
||
19 | name: 'Col1', |
||
20 | dataIndex: 'col1' |
||
21 | }, |
||
22 | { |
||
23 | name: 'Col2', |
||
24 | dataIndex: 'col2' |
||
25 | }, |
||
26 | { |
||
27 | name: 'Col3', |
||
28 | dataIndex: 'col3' |
||
29 | } |
||
30 | ], |
||
31 | stateKey: 'test-grid' |
||
32 | }; |
||
33 | |||
34 | expect(reorderColumn(action)) |
||
35 | .toEqual({ |
||
36 | columns: [ |
||
37 | { |
||
38 | name: 'Col2', |
||
39 | dataIndex: 'col2' |
||
40 | }, |
||
41 | { |
||
42 | name: 'Col1', |
||
43 | dataIndex: 'col1' |
||
44 | }, |
||
45 | { |
||
46 | name: 'Col3', |
||
47 | dataIndex: 'col3' |
||
48 | } |
||
49 | ], |
||
50 | stateKey: 'test-grid', |
||
51 | stateful: undefined, |
||
52 | type: SET_COLUMNS |
||
53 | }); |
||
54 | }); |
||
55 | |||
56 | it('Should keep columns in same order even on drop', () => { |
||
57 | const action = { |
||
58 | draggedIndex: 0, |
||
59 | droppedIndex: 0, |
||
60 | columns: [ |
||
61 | { |
||
62 | name: 'Col1', |
||
63 | dataIndex: 'col1' |
||
64 | }, |
||
65 | { |
||
66 | name: 'Col2', |
||
67 | dataIndex: 'col2' |
||
68 | }, |
||
69 | { |
||
70 | name: 'Col3', |
||
71 | dataIndex: 'col3' |
||
72 | } |
||
73 | ], |
||
74 | stateKey: 'test-grid' |
||
75 | }; |
||
76 | |||
77 | expect(reorderColumn(action)) |
||
78 | .toEqual({ |
||
79 | columns: [ |
||
80 | { |
||
81 | name: 'Col1', |
||
82 | dataIndex: 'col1' |
||
83 | }, |
||
84 | { |
||
85 | name: 'Col2', |
||
86 | dataIndex: 'col2' |
||
87 | }, |
||
88 | { |
||
89 | name: 'Col3', |
||
90 | dataIndex: 'col3' |
||
91 | } |
||
92 | ], |
||
93 | stateKey: 'test-grid', |
||
94 | stateful: undefined, |
||
95 | type: SET_COLUMNS |
||
96 | }); |
||
97 | }); |
||
98 | |||
99 | }); |
||
100 |