Skip to content

Commit 11608ab

Browse files
committed
Add expect support for "not" statements
1 parent 92582f6 commit 11608ab

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/expect.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@ function toDispatchActions(expectedActions, done) {
1313
return assertions.toDispatchActions(this.actual, expectedActions, done);
1414
}
1515

16+
function toNotDispatchActions(expectedActions, done) {
17+
if (this.state) {
18+
return assertions.toNotDispatchActionsWithState(this.state, this.actual, expectedActions, done);
19+
}
20+
return assertions.toNotDispatchActions(this.actual, expectedActions, done);
21+
}
22+
1623
function registerAssertions() {
1724
expect.extend({
1825
toDispatchActions,
26+
toNotDispatchActions,
1927
withState
2028
});
2129
}

test/expect/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,24 @@ describe('expect', () => {
4141
.toDispatchActions(actions.expectedParentActions, done);
4242
});
4343
});
44+
45+
describe('.toNotDispatchActions', () => {
46+
it('should accept single action', (done) => {
47+
expect(actions.start()).toNotDispatchActions(actions.anotherStart(), done);
48+
});
49+
50+
it('should accept array with one action', (done) => {
51+
expect(actions.start()).toNotDispatchActions([actions.anotherStart()], done);
52+
});
53+
54+
it('should accept array with multiple actions', (done) => {
55+
expect(actions.asyncActionCreator())
56+
.toNotDispatchActions(actions.anotherExpectedActions, done);
57+
});
58+
59+
it('should accept array with nested async action creators', (done) => {
60+
expect(actions.parentAsyncActionCreator())
61+
.toNotDispatchActions(actions.anotherParentExpectedActions, done);
62+
});
63+
});
4464
});

test/general/initialState.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import expect from 'expect';
2-
import getInitialStoreState, {
2+
import {
33
buildInitialStoreState,
4-
registerInitialStoreState
4+
registerInitialStoreState,
5+
getInitialStoreState
56
} from '../../src/initialState';
67
import { expectedInitialState, reducerWithNesterReducers } from '../testingData/reducers';
78

0 commit comments

Comments
 (0)