|
1
|
|
|
/* eslint-enable describe it */ |
|
2
|
|
|
import expect from 'expect'; |
|
3
|
|
|
import { fromJS } from 'immutable'; |
|
4
|
|
|
|
|
5
|
|
|
import { |
|
6
|
|
|
SET_COLUMNS, |
|
7
|
|
|
RESIZE_COLUMNS, |
|
8
|
|
|
SET_SORT_DIRECTION |
|
9
|
|
|
} from './../../../src/constants/ActionTypes'; |
|
10
|
|
|
|
|
11
|
|
|
import |
|
12
|
|
|
grid |
|
13
|
|
|
from './../../../src/reducers/components/grid'; |
|
14
|
|
|
|
|
15
|
|
|
import { |
|
16
|
|
|
resetLastUpdate |
|
17
|
|
|
} from './../../../src/util/lastUpdate'; |
|
18
|
|
|
|
|
19
|
|
|
const columns = [ |
|
20
|
|
|
{ |
|
21
|
|
|
name: 'col1', |
|
22
|
|
|
renderer: () => {}, |
|
23
|
|
|
dataIndex: 'col-1' |
|
24
|
|
|
}, |
|
25
|
|
|
{ |
|
26
|
|
|
name: 'col2', |
|
27
|
|
|
dataIndex: 'col-2' |
|
28
|
|
|
} |
|
29
|
|
|
]; |
|
30
|
|
|
|
|
31
|
|
|
describe('The grid reducer setCol func', () => { |
|
32
|
|
|
beforeEach(() => resetLastUpdate()); |
|
33
|
|
|
|
|
34
|
|
|
const state = fromJS({}); |
|
35
|
|
|
|
|
36
|
|
|
const action = { |
|
37
|
|
|
stateKey: 'test-grid', |
|
38
|
|
|
type: SET_COLUMNS, |
|
39
|
|
|
columns |
|
40
|
|
|
}; |
|
41
|
|
|
|
|
42
|
|
|
const outState = fromJS({ |
|
43
|
|
|
'test-grid': { |
|
44
|
|
|
columns, |
|
45
|
|
|
lastUpdate: 1 |
|
46
|
|
|
} |
|
47
|
|
|
}); |
|
48
|
|
|
|
|
49
|
|
|
it('Should set passing cols', () => { |
|
50
|
|
|
expect( |
|
51
|
|
|
grid(state, action) |
|
52
|
|
|
).toEqualImmutable(outState); |
|
53
|
|
|
}); |
|
54
|
|
|
|
|
55
|
|
|
}); |
|
56
|
|
|
|
|
57
|
|
|
describe('The grid reducer SET_SORT_DIRECTION func', () => { |
|
58
|
|
|
beforeEach(() => resetLastUpdate()); |
|
59
|
|
|
|
|
60
|
|
|
const state = fromJS({}); |
|
61
|
|
|
|
|
62
|
|
|
const action = { |
|
63
|
|
|
stateKey: 'test-grid', |
|
64
|
|
|
type: SET_SORT_DIRECTION, |
|
65
|
|
|
columns |
|
66
|
|
|
}; |
|
67
|
|
|
|
|
68
|
|
|
const outState = fromJS({ |
|
69
|
|
|
'test-grid': { |
|
70
|
|
|
columns, |
|
71
|
|
|
lastUpdate: 1 |
|
72
|
|
|
} |
|
73
|
|
|
}); |
|
74
|
|
|
|
|
75
|
|
|
it('Should set cols after sort action', () => { |
|
76
|
|
|
expect( |
|
77
|
|
|
grid(state, action) |
|
78
|
|
|
).toEqualImmutable(outState); |
|
79
|
|
|
}); |
|
80
|
|
|
}); |
|
81
|
|
|
|
|
82
|
|
|
describe('The grid reducer resizeCols func', () => { |
|
83
|
|
|
beforeEach(() => resetLastUpdate()); |
|
84
|
|
|
|
|
85
|
|
|
const state = fromJS({}); |
|
86
|
|
|
|
|
87
|
|
|
const action = { |
|
88
|
|
|
stateKey: 'test-grid', |
|
89
|
|
|
type: RESIZE_COLUMNS, |
|
90
|
|
|
columns |
|
91
|
|
|
}; |
|
92
|
|
|
|
|
93
|
|
|
const outState = fromJS({ |
|
94
|
|
|
'test-grid': { |
|
95
|
|
|
columns, |
|
96
|
|
|
lastUpdate: 1 |
|
97
|
|
|
} |
|
98
|
|
|
}); |
|
99
|
|
|
|
|
100
|
|
|
it('Should set cols after resize action', () => { |
|
101
|
|
|
expect( |
|
102
|
|
|
grid(state, action) |
|
103
|
|
|
).toEqualImmutable(outState); |
|
104
|
|
|
}); |
|
105
|
|
|
|
|
106
|
|
|
}); |