Created
March 21, 2018 13:03
-
-
Save tlaitinen/2917636e0a9be1e0149fef153e7ce142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {actions, reducer} from './ui'; | |
| describe('ui actions', () => { | |
| it('should create an action to set loading state', () => { | |
| expect(actions.setLoading(true)).toEqual({ | |
| type: 'UI_SET_LOADING', | |
| payload: true | |
| }); | |
| }); | |
| it('should create an action to show modal', () => { | |
| expect(actions.showModal({type:'dummy'})).toEqual({ | |
| type: 'UI_SHOW_MODAL', | |
| payload: {type:'dummy'} | |
| }); | |
| }); | |
| it('should create an action to hide modal', () => { | |
| expect(actions.hideModal()).toEqual({ | |
| type: 'UI_HIDE_MODAL' | |
| }); | |
| }); | |
| }); | |
| describe('ui reducer', () => { | |
| it('should return the initial state', () => { | |
| expect(reducer(undefined, {})).toEqual({ | |
| loading: true, | |
| modals: [] | |
| }); | |
| }); | |
| it('should handle UI_SET_LOADING', () => { | |
| expect(reducer(undefined, actions.setLoading(false))).toEqual({ | |
| loading: false, | |
| modals: [] | |
| }); | |
| }); | |
| it('should handle UI_SHOW_MODAL', () => { | |
| expect( | |
| reducer( | |
| { | |
| loading:false, | |
| modals:[{type:'dummy'}] | |
| }, | |
| actions.showModal({type:'dummy'}) | |
| ) | |
| ).toEqual({ | |
| loading: false, | |
| modals: [{type:'dummy'}, {type:'dummy'}] | |
| }); | |
| }); | |
| it('should handle UI_HIDE_MODAL', () => { | |
| expect( | |
| reducer( | |
| { | |
| loading:false, | |
| modals: [{type:'dummy'}, {type:'dummy'}] | |
| }, | |
| actions.hideModal() | |
| ) | |
| ).toEqual({ | |
| loading: false, | |
| modals: [{type:'dummy'}] | |
| }); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment