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
|
import reduceOption, * as optionActions from '../../../ducks/ui/option'
describe('option reducer', () => {
it('should return the initial state', () => {
expect(reduceOption(undefined, {})).toEqual({})
})
let state = undefined
it('should handle option update start', () => {
state = reduceOption(undefined, {
type: optionActions.OPTION_UPDATE_START, option: 'foo', value: 'bar'
})
expect(state).toEqual({
foo: {
error: false,
isUpdating: true,
value: 'bar'
}
})
})
it('should handle option update success', () => {
expect(reduceOption(state, {
type: optionActions.OPTION_UPDATE_SUCCESS, option: 'foo'
})).toEqual({})
})
it('should handle option update error', () => {
expect(reduceOption(undefined, {
type: optionActions.OPTION_UPDATE_ERROR, option: 'foo', error: 'errorMsg'
})).toEqual({
foo: {
error: 'errorMsg',
isUpdating: false,
}
})
})
})
|