Skip to content

Commit b2bed15

Browse files
committed
Update docs
1 parent ce294c9 commit b2bed15

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

docs/javascript.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
## Registration
44

5-
For plain javascript assertions you don't need to register anything. Just import assertions in your tests:
6-
75
```js
86
// using ES6 modules
97
import { assertions } from 'redux-actions-assertions';
108

119
// using CommonJS modules
12-
var assertions = require('redux-actions-assertions');
10+
var assertions = require('redux-actions-assertions').assertions;
1311

1412
// in test
1513
assertions.toDispatchActions(/**/)
@@ -18,6 +16,8 @@ assertions.toDispatchActionsWithState(/**/);
1816
assertions.toNotDispatchActionsWithState(/**/);
1917
```
2018

19+
For plain javascript assertions you don't need to register anything. Just import assertions in your tests:
20+
2121
## Usage
2222

2323
### toDispatchActions

docs/tape.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,28 @@ import { assertions } from 'redux-actions-assertions'
99

1010
// using CommonJS modules
1111
var test = require('tape')
12-
var assertions = require('redux-actions-assertions');
12+
var assertions = require('redux-actions-assertions').assertions;
1313
```
1414

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+
1517
### toDispatchActions
1618
> `toDispatchActions(action, expectedActions, done, fail)`
1719
1820
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.
1921

2022
```js
23+
// Using `t.plan`
2124
test('Thunk: editTag', (t) => {
25+
t.plan(1)
2226
toDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail);
2327
})
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+
})
2434
```
2535

2636
### toNotDispatchActions
@@ -30,6 +40,7 @@ Asserts that when given `action` is dispatched it will not dispatch `expectedAct
3040

3141
```js
3242
test('Thunk: editTag', (t) => {
43+
t.plan(1)
3344
toNotDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail);
3445
})
3546
```
@@ -42,6 +53,7 @@ Same as `toDispatchActions` + asserts that store initialised with `state` before
4253

4354
```js
4455
test('Thunk: editTag', (t) => {
56+
t.plan(1)
4557
toDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail);
4658
})
4759
```
@@ -54,6 +66,7 @@ Same as `toNotDispatchActions` + asserts that store initialised with `state` bef
5466

5567
```js
5668
test('Thunk: editTag', (t) => {
69+
t.plan(1)
5770
toNotDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail);
5871
})
5972
```

0 commit comments

Comments
 (0)