-
Notifications
You must be signed in to change notification settings - Fork 16
/
test.js
43 lines (36 loc) · 1.04 KB
/
test.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
import Immutable from 'seamless-immutable';
import createReducer from '../../creators/createReducer';
import onCycle from '.';
const initialState = {
letterArray: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
};
const setUp = {
state: null
};
beforeEach(() => {
setUp.state = Immutable(initialState);
});
describe('onCycle', () => {
it('Cycle array two positions forward', () => {
const reducer = createReducer(setUp.state, {
'@@ACTION/CYCLE': onCycle()
});
const newState = reducer(setUp.state, {
type: '@@ACTION/CYCLE',
target: 'letterArray',
step: 2
});
expect(newState.letterArray).toEqual(['C', 'D', 'E', 'F', 'G', 'H', 'A', 'B']);
});
it('Cycling array two positions backwards', () => {
const reducer = createReducer(setUp.state, {
'@@ACTION/CYCLE': onCycle()
});
const newState = reducer(setUp.state, {
type: '@@ACTION/CYCLE',
target: 'letterArray',
step: -2
});
expect(newState.letterArray).toEqual(['G', 'H', 'A', 'B', 'C', 'D', 'E', 'F']);
});
});