|
| 1 | +# [tape](https://github.com/substack/tape) |
| 2 | + |
| 3 | +## Usage |
| 4 | + |
| 5 | +```js |
| 6 | +// using ES6 modules |
| 7 | +import test from 'tape' |
| 8 | +import { assertions } from 'redux-actions-assertions' |
| 9 | + |
| 10 | +// using CommonJS modules |
| 11 | +var test = require('tape') |
| 12 | +var assertions = require('redux-actions-assertions'); |
| 13 | +``` |
| 14 | + |
| 15 | +### toDispatchActions |
| 16 | +> `toDispatchActions(action, expectedActions, done, fail)` |
| 17 | +
|
| 18 | +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. |
| 19 | + |
| 20 | +```js |
| 21 | +test('Thunk: editTag', (t) => { |
| 22 | + toDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail); |
| 23 | +}) |
| 24 | +``` |
| 25 | + |
| 26 | +### toNotDispatchActions |
| 27 | +> `toNotDispatchActions(action, expectedActions, done, fail)` |
| 28 | +
|
| 29 | +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. |
| 30 | + |
| 31 | +```js |
| 32 | +test('Thunk: editTag', (t) => { |
| 33 | + toNotDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail); |
| 34 | +}) |
| 35 | +``` |
| 36 | + |
| 37 | +### toDispatchActionsWithState |
| 38 | + |
| 39 | +> `toDispatchActionsWithState(initialState, action, expectedActions, done, fail)` |
| 40 | +
|
| 41 | +Same as `toDispatchActions` + asserts that store initialised with `state` before `action` is dispatched. |
| 42 | + |
| 43 | +```js |
| 44 | +test('Thunk: editTag', (t) => { |
| 45 | + toDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail); |
| 46 | +}) |
| 47 | +``` |
| 48 | + |
| 49 | +### toNotDispatchActionsWithState |
| 50 | + |
| 51 | +> `toNotDispatchActionsWithState(initialState, action, expectedActions, done, fail)` |
| 52 | +
|
| 53 | +Same as `toNotDispatchActions` + asserts that store initialised with `state` before `action` is dispatched. |
| 54 | + |
| 55 | +```js |
| 56 | +test('Thunk: editTag', (t) => { |
| 57 | + toNotDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail); |
| 58 | +}) |
| 59 | +``` |
0 commit comments