|
| 1 | +import should from 'should'; |
| 2 | +import thunk from 'redux-thunk'; |
| 3 | +import { registerMiddlewares } from '../../src'; |
| 4 | +import { registerAssertions } from '../../src/should'; |
| 5 | +import actions from '../testingData/actions'; |
| 6 | + |
| 7 | +registerMiddlewares([thunk]); |
| 8 | +registerAssertions(); |
| 9 | + |
| 10 | +describe('should', () => { |
| 11 | + describe('.withState', () => { |
| 12 | + it('should accept object', (done) => { |
| 13 | + should(actions.actionCreatorWithGetState()) |
| 14 | + .withState({ property: 'value' }) |
| 15 | + .dispatchActions(actions.actionWithGetState({ property: 'value' }), done); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should accept function', (done) => { |
| 19 | + should(actions.actionCreatorWithGetState()) |
| 20 | + .withState(() => { return { property: 'value' };}) |
| 21 | + .dispatchActions(actions.actionWithGetState({ property: 'value' }), done); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should work with .should', (done) => { |
| 25 | + actions.actionCreatorWithGetState().should |
| 26 | + .withState(() => { return { property: 'value' };}) |
| 27 | + .dispatchActions(actions.actionWithGetState({ property: 'value' }), done); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should have alias .state', (done) => { |
| 31 | + should(actions.actionCreatorWithGetState()) |
| 32 | + .with.state(() => { return { property: 'value1' };}) |
| 33 | + .dispatchActions(actions.actionWithGetState({ property: 'value' }), done); |
| 34 | + }); |
| 35 | + }); |
| 36 | + |
| 37 | + describe('.dispatchActions', () => { |
| 38 | + it('should accept single action', (done) => { |
| 39 | + should(actions.start()).dispatchActions(actions.start(), done); |
| 40 | + }); |
| 41 | + |
| 42 | + it('should accept array with one action', (done) => { |
| 43 | + should(actions.start()).dispatchActions([actions.start()], done); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should accept array with multiple actions', (done) => { |
| 47 | + should(actions.asyncActionCreator()) |
| 48 | + .dispatchActions(actions.expectedActions, done); |
| 49 | + }); |
| 50 | + |
| 51 | + it('should accept array with nested async action creators', (done) => { |
| 52 | + should(actions.parentAsyncActionCreator()) |
| 53 | + .dispatchActions(actions.expectedParentActions, done); |
| 54 | + }); |
| 55 | + |
| 56 | + it('should work with .should', (done) => { |
| 57 | + actions.parentAsyncActionCreator().should |
| 58 | + .dispatchActions(actions.expectedParentActions, done); |
| 59 | + }); |
| 60 | + }); |
| 61 | +}); |
0 commit comments