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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
jest.unmock('../../ducks/flows')
jest.unmock('../../ducks/flowView')
jest.unmock('../../ducks/utils/view')
jest.unmock('../../ducks/utils/list')
jest.unmock('./tutils')
import { createStore } from './tutils'
import flows, * as flowActions from '../../ducks/flows'
import flowView, * as flowViewActions from '../../ducks/flowView'
function testStore() {
let store = createStore({
flows,
flowView
})
for (let i of [1, 2, 3, 4]) {
store.dispatch(
flowActions.addFlow({ id: i })
)
}
return store
}
describe('select relative', () => {
function testSelect(start, relative, result) {
const store = testStore()
store.dispatch(flowActions.select(start))
expect(store.getState().flows.selected).toEqual(start ? [start] : [])
store.dispatch(flowViewActions.selectRelative(relative))
expect(store.getState().flows.selected).toEqual([result])
}
describe('previous', () => {
it('should select the previous flow', () => {
testSelect(3, -1, 2)
})
it('should not changed when first flow is selected', () => {
testSelect(1, -1, 1)
})
it('should select first flow if no flow is selected', () => {
testSelect(undefined, -1, 1)
})
})
describe('next', () => {
it('should select the next flow', () => {
testSelect(2, 1, 3)
})
it('should not changed when last flow is selected', () => {
testSelect(4, 1, 4)
})
it('should select last flow if no flow is selected', () => {
testSelect(undefined, 1, 4)
})
})
})
|