|
| 1 | +# [jasmine](https://github.com/jasmine/jasmine) |
| 2 | + |
| 3 | +## Registration |
| 4 | + |
| 5 | +```js |
| 6 | +// using ES6 modules |
| 7 | +import { registerAssertions } from 'redux-actions-assertions/jasmine'; |
| 8 | + |
| 9 | +// using CommonJS modules |
| 10 | +var registerAssertions = require('redux-actions-assertions/jasmine').registerAssertions; |
| 11 | + |
| 12 | +// registration |
| 13 | +beforeEach(registerAssertions); |
| 14 | +``` |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +### .toDispatchActions |
| 19 | + |
| 20 | +> `expect(action).toDispatchActions(expectedActions, done)` |
| 21 | +
|
| 22 | +Asserts that when given `action` is dispatched it will dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions. |
| 23 | + |
| 24 | +```js |
| 25 | +expect(myActionCreator()) |
| 26 | + .toDispatchActions({ type: 'MY_ACTION_START' }, done); |
| 27 | +``` |
| 28 | + |
| 29 | +### .not.toDispatchActions |
| 30 | + |
| 31 | +> `expect(action).not.toDispatchActions(expectedActions, done)` |
| 32 | +
|
| 33 | +Asserts that when given `action` is dispatched it will not dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions. |
| 34 | + |
| 35 | +```js |
| 36 | +expect(myActionCreator()) |
| 37 | + .not.toDispatchActions({ type: 'MY_ACTION_START' }, done); |
| 38 | +``` |
| 39 | + |
| 40 | +### .toDispatchActionsWithState |
| 41 | + |
| 42 | +> `expect(action).toDispatchActionsWithState(state, expectedActions, done)` |
| 43 | +
|
| 44 | +Asserts that store initialised with `state` before `action` is dispatched. |
| 45 | + |
| 46 | +```js |
| 47 | +const state = {property: 'value'}; |
| 48 | +const expectedActions = [{ type: 'MY_ACTION_START' }, finishActionCreator()]; |
| 49 | +expect(myActionCreator()) |
| 50 | + .toDispatchActionsWithState(state, expectedActions, done); |
| 51 | +``` |
| 52 | +You can also use it with `.not`: |
| 53 | + |
| 54 | +```js |
| 55 | +expect(myActionCreator()) |
| 56 | + .not.toDispatchActionsWithState(state, expectedActions, done); |
| 57 | +``` |
0 commit comments