-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtest.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 onAppend from '.';
const initialState = {
numberArray: [4, 2, 3, 4, 1]
};
const setUp = {
state: null
};
beforeEach(() => {
setUp.state = Immutable(initialState);
});
describe('onAppend', () => {
it('Appends integer to integer array', () => {
const reducer = createReducer(setUp.state, {
'@@ACTION/APPEND_INTEGER': onAppend()
});
const newState = reducer(setUp.state, {
type: '@@ACTION/APPEND_INTEGER',
payload: 7,
target: 'numberArray'
});
expect(newState.numberArray).toEqual([4, 2, 3, 4, 1, 7]);
});
it('Appends objects based on a payload', () => {
const reducer = createReducer(setUp.state, {
'@@ACTION/APPEND_INTEGER': onAppend(action => action.payload.id)
});
const newState = reducer(setUp.state, {
type: '@@ACTION/APPEND_INTEGER',
payload: { id: 8 },
target: 'numberArray'
});
expect(newState.numberArray).toEqual([4, 2, 3, 4, 1, 8]);
});
});