Skip to content

Commit ed1e513

Browse files
committed
Add "should" usage
1 parent c326d3d commit ed1e513

File tree

1 file changed

+52
-7
lines changed

1 file changed

+52
-7
lines changed

README.md

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ assertions.toDispatchActionsWithState(/**/);
8585
### Usage
8686

8787
#### toDispatchActions
88-
> `toDispatchActions(action, expectedActions, done)`
88+
> `toDispatchActions(action, expectedActions, callback)`
8989
9090
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.
9191

@@ -95,7 +95,7 @@ toDispatchActions(testActionCreator(), [{type: 'MY_ACTION_START'}], callback);
9595

9696
#### toDispatchActionsWithState
9797

98-
> `toDispatchActionsWithState(initialState, action, expectedActions, done)`
98+
> `toDispatchActionsWithState(initialState, action, expectedActions, callback)`
9999
100100
Same as `toDispatchActions` + asserts that store initialised with `state` before `action` is dispatched.
101101

@@ -119,7 +119,7 @@ registerAssertions();
119119
```
120120
### Usage
121121

122-
#### toDispatchActions
122+
#### .toDispatchActions
123123

124124
> `expect(action).toDispatchActions(expectedActions, callback)`
125125
@@ -130,9 +130,9 @@ expect(myActionCreator())
130130
.toDispatchActions({type: 'MY_ACTION_START'}, callback);
131131
```
132132

133-
#### withState
133+
#### .withState
134134

135-
> `expect(action).withState(state).toDispatchActions(expectedActions)`
135+
> `expect(action).withState(state).toDispatchActions(expectedActions, callback)`
136136
137137
Asserts that store initialised with `state` before `action` is dispatched.
138138

@@ -157,7 +157,7 @@ var registerAssertions = require('redux-actions-assertions/chai').registerAssert
157157
registerAssertions();
158158
```
159159

160-
#### .to.dispatch.actions(assert.isDispatching)
160+
#### .to.dispatch.actions or assert.isDispatching
161161

162162
> `expect(action).to.dispatch.actions(expectedActions, callback)`
163163
@@ -181,7 +181,7 @@ assert.isDispatching(
181181
);
182182
```
183183

184-
#### .with.state(assert.isDispatchingWithState)
184+
#### .with.state or assert.isDispatchingWithState
185185

186186
> `expect(action).with.state(state).to.dispatch.actions(expectedActions, callback)`
187187
@@ -236,6 +236,51 @@ var registerAssertions = require('redux-actions-assertions/should').registerAsse
236236
// registration
237237
registerAssertions();
238238
```
239+
240+
### Usage
241+
242+
#### .dispatchActions
243+
244+
> `should(action).dispatchActions(expectedActions, callback)`
245+
> `action.should.dispatchActions(expectedActions, callback)`
246+
247+
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.
248+
249+
```js
250+
should(myActionCreator())
251+
.dispatchActions({type: 'MY_ACTION_START'}, callback);
252+
253+
myActionCreator().should
254+
.dispatchActions({type: 'MY_ACTION_START'}, callback);
255+
```
256+
257+
#### .withState or with.state
258+
259+
> `should(action).withState(state).dispatchActions(expectedActions, callback)`
260+
> `should(action).with.state(state).dispatchActions(expectedActions, callback)`
261+
262+
> `action.should.withState(state).dispatchActions(expectedActions, callback)`
263+
> `action.should.with.state(state).dispatchActions(expectedActions, callback)`
264+
265+
Asserts that store initialised with `state` before `action` is dispatched.
266+
267+
```js
268+
should(myActionCreator())
269+
.withState({property: 'value'})
270+
.dispatchActions({type: 'MY_ACTION_START'}, callback);
271+
272+
should(myActionCreator())
273+
.with.state({property: 'value'})
274+
.dispatchActions({type: 'MY_ACTION_START'}, callback);
275+
276+
myActionCreator().should
277+
.withState({property: 'value'})
278+
.dispatchActions({type: 'MY_ACTION_START'}, callback);
279+
280+
myActionCreator().should
281+
.with.state({property: 'value'})
282+
.dispatchActions({type: 'MY_ACTION_START'}, callback);
283+
```
239284
## [jasmine](https://github.com/jasmine/jasmine) and [jest](https://github.com/facebook/jest)
240285

241286
### Registration

0 commit comments

Comments
 (0)