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