Skip to content

Commit f63c61e

Browse files
committed
Update readme, add documentation for usage with jasmine
1 parent f16cb94 commit f63c61e

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ It use [redux-mock-store](https://github.com/arnaudbenard/redux-mock-store) to m
1111
- [chai](https://redux-things.github.io/redux-actions-assertions/chai.html)
1212
- [expect](https://redux-things.github.io/redux-actions-assertions/expect.html)
1313
- [expect.js](https://redux-things.github.io/redux-actions-assertions/expectjs.html)
14+
- [jasmine](https://redux-things.github.io/redux-actions-assertions/jasmine.html)
1415
- [should](https://redux-things.github.io/redux-actions-assertions/should.html)
1516
- [tape](https://redux-things.github.io/redux-actions-assertions/tape.html)
1617
- [pure javascript assertion](https://redux-things.github.io/redux-actions-assertions/javascript.html)

documentation/jasmine.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
```

test/jasmine/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import actions from '../testingData/actions';
66

77
registerMiddlewares([thunk]);
88

9+
beforeEach(registerAssertions);
10+
911
describe('jasmine', () => {
10-
beforeEach(() => { registerAssertions(); });
1112
describe('toDispatchActionsWithState', () => {
1213
it('should accept object', (done) => {
1314
const state = { property: 'value' };

0 commit comments

Comments
 (0)