|
| 1 | +/* eslint-env jasmine */ |
| 2 | +import thunk from 'redux-thunk'; |
| 3 | +import { registerMiddlewares } from '../../src'; |
| 4 | +import { registerAssertions } from '../../src/jasmine'; |
| 5 | +import actions from '../testingData/actions'; |
| 6 | + |
| 7 | +registerMiddlewares([thunk]); |
| 8 | + |
| 9 | +beforeEach(registerAssertions); |
| 10 | + |
| 11 | +describe('jasmine', () => { |
| 12 | + describe('toDispatchActionsWithState', () => { |
| 13 | + it('should accept object', (done) => { |
| 14 | + const state = { property: 'value' }; |
| 15 | + expect(actions.actionCreatorWithGetState()) |
| 16 | + .toDispatchActionsWithState(state, actions.actionWithGetState({ property: 'value' }), done); |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + describe('.toDispatchActions', () => { |
| 21 | + it('should accept single action', (done) => { |
| 22 | + expect(actions.start()).toDispatchActions(actions.start(), done); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should accept array with one action', (done) => { |
| 26 | + expect(actions.start()).toDispatchActions([actions.start()], done); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should accept array with multiple actions', (done) => { |
| 30 | + expect(actions.asyncActionCreator()) |
| 31 | + .toDispatchActions(actions.expectedActions, done); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should accept array with nested async action creators', (done) => { |
| 35 | + expect(actions.parentAsyncActionCreator()) |
| 36 | + .toDispatchActions(actions.expectedParentActions, done); |
| 37 | + }); |
| 38 | + }); |
| 39 | + |
| 40 | + describe('.toNotDispatchActions', () => { |
| 41 | + it('should accept single action', (done) => { |
| 42 | + expect(actions.start()).toNotDispatchActions(actions.anotherStart(), done); |
| 43 | + }); |
| 44 | + |
| 45 | + it('should accept array with one action', (done) => { |
| 46 | + expect(actions.start()).toNotDispatchActions([actions.anotherStart()], done); |
| 47 | + }); |
| 48 | + |
| 49 | + it('should accept array with multiple actions', (done) => { |
| 50 | + expect(actions.asyncActionCreator()) |
| 51 | + .toNotDispatchActions(actions.anotherExpectedActions, done); |
| 52 | + }); |
| 53 | + |
| 54 | + it('should accept array with nested async action creators', (done) => { |
| 55 | + expect(actions.parentAsyncActionCreator()) |
| 56 | + .toNotDispatchActions(actions.anotherParentExpectedActions, done); |
| 57 | + }); |
| 58 | + }); |
| 59 | + |
| 60 | + describe('.not.toDispatchActions', () => { |
| 61 | + it('should accept single action', (done) => { |
| 62 | + expect(actions.start()).not.toDispatchActions(actions.anotherStart(), done); |
| 63 | + }); |
| 64 | + |
| 65 | + it('should accept array with one action', (done) => { |
| 66 | + expect(actions.start()).not.toDispatchActions([actions.anotherStart()], done); |
| 67 | + }); |
| 68 | + |
| 69 | + it('should accept array with multiple actions', (done) => { |
| 70 | + expect(actions.asyncActionCreator()) |
| 71 | + .not.toDispatchActions(actions.anotherExpectedActions, done); |
| 72 | + }); |
| 73 | + |
| 74 | + it('should accept array with nested async action creators', (done) => { |
| 75 | + expect(actions.parentAsyncActionCreator()) |
| 76 | + .not.toDispatchActions(actions.anotherParentExpectedActions, done); |
| 77 | + }); |
| 78 | + }); |
| 79 | +}); |
0 commit comments