|  | 
|  | 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').assertions; | 
|  | 13 | +``` | 
|  | 14 | + | 
|  | 15 | +Usage is the same as the [plain JavaScript assertions](https://redux-things.github.io/redux-actions-assertions/javascript.html), you just need to set up the correct `pass` and `fail` callbacks. Also, be sure to call `end` in a `Promise.then`, or `plan` with the number of assertions you're making in the test (see below). | 
|  | 16 | + | 
|  | 17 | +### toDispatchActions | 
|  | 18 | +> `toDispatchActions(action, expectedActions, done, fail)` | 
|  | 19 | +
 | 
|  | 20 | +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. | 
|  | 21 | + | 
|  | 22 | +```js | 
|  | 23 | +// Using `t.plan` | 
|  | 24 | +test('Thunk: editTag', (t) => { | 
|  | 25 | +  t.plan(1) | 
|  | 26 | +  toDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail); | 
|  | 27 | +}) | 
|  | 28 | + | 
|  | 29 | +// Using `t.end` | 
|  | 30 | +test('Thunk: editTag', (t) => { | 
|  | 31 | +  toDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail) | 
|  | 32 | +    .then(t.end); | 
|  | 33 | +}) | 
|  | 34 | +``` | 
|  | 35 | + | 
|  | 36 | +### toNotDispatchActions | 
|  | 37 | +> `toNotDispatchActions(action, expectedActions, done, fail)` | 
|  | 38 | +
 | 
|  | 39 | +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. | 
|  | 40 | + | 
|  | 41 | +```js | 
|  | 42 | +test('Thunk: editTag', (t) => { | 
|  | 43 | +  t.plan(1) | 
|  | 44 | +  toNotDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail); | 
|  | 45 | +}) | 
|  | 46 | +``` | 
|  | 47 | + | 
|  | 48 | +### toDispatchActionsWithState | 
|  | 49 | + | 
|  | 50 | +> `toDispatchActionsWithState(initialState, action, expectedActions, done, fail)` | 
|  | 51 | +
 | 
|  | 52 | +Same as `toDispatchActions` + asserts that store initialised with `state` before `action` is dispatched. | 
|  | 53 | + | 
|  | 54 | +```js | 
|  | 55 | +test('Thunk: editTag', (t) => { | 
|  | 56 | +  t.plan(1) | 
|  | 57 | +  toDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail); | 
|  | 58 | +}) | 
|  | 59 | +``` | 
|  | 60 | + | 
|  | 61 | +### toNotDispatchActionsWithState | 
|  | 62 | + | 
|  | 63 | +> `toNotDispatchActionsWithState(initialState, action, expectedActions, done, fail)` | 
|  | 64 | +
 | 
|  | 65 | +Same as `toNotDispatchActions` + asserts that store initialised with `state` before `action` is dispatched. | 
|  | 66 | + | 
|  | 67 | +```js | 
|  | 68 | +test('Thunk: editTag', (t) => { | 
|  | 69 | +  t.plan(1) | 
|  | 70 | +  toNotDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail); | 
|  | 71 | +}) | 
|  | 72 | +``` | 
0 commit comments