-
Notifications
You must be signed in to change notification settings - Fork 16
/
test.js
42 lines (35 loc) · 1.09 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
import Immutable from 'seamless-immutable';
import createReducer from '../../creators/createReducer';
import onSpreadValue from '.';
const initialState = {
key1: null,
key2: null
};
const setUp = {
state: null
};
beforeEach(() => {
setUp.state = Immutable(initialState);
});
describe('onSpreadValue', () => {
it('Spread the payload in the state', () => {
const payload = { key1: '2', key2: 42 };
const reducer = createReducer(setUp.state, {
'@@ACTION/TYPE': onSpreadValue()
});
const newState = reducer(setUp.state, { type: '@@ACTION/TYPE', payload });
Object.keys(payload).forEach(key => {
expect(newState[key]).toBe(payload[key]);
});
});
it('Spread the payload in the state using selector', () => {
const payload = { key1: '2', key2: 42 };
const reducer = createReducer(setUp.state, {
'@@ACTION/TYPE': onSpreadValue(action => action.data)
});
const newState = reducer(setUp.state, { type: '@@ACTION/TYPE', data: payload });
Object.keys(payload).forEach(key => {
expect(newState[key]).toBe(payload[key]);
});
});
});