diff options
Diffstat (limited to 'web/src/js/__tests__/ducks/ui/optionSpec.js')
-rw-r--r-- | web/src/js/__tests__/ducks/ui/optionSpec.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/web/src/js/__tests__/ducks/ui/optionSpec.js b/web/src/js/__tests__/ducks/ui/optionSpec.js new file mode 100644 index 00000000..4b6b43cc --- /dev/null +++ b/web/src/js/__tests__/ducks/ui/optionSpec.js @@ -0,0 +1,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, + } + }) + }) +}) |