Skip to content

Commit 72fbfb0

Browse files
committed
Add expect.js support for "not" statement
1 parent 11608ab commit 72fbfb0

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/expectjs.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@ function dispatchActions(expectedActions, done) {
1010
if (this.obj instanceof ActionWithInitialState) {
1111
const action = this.obj.action;
1212
const state = this.obj.state;
13-
assertions.toDispatchActionsWithState(state, action, expectedActions, done);
13+
if (this.flags.not) {
14+
assertions.toNotDispatchActionsWithState(state, action, expectedActions, done);
15+
} else {
16+
assertions.toDispatchActionsWithState(state, action, expectedActions, done);
17+
}
1418
} else {
15-
assertions.toDispatchActions(this.obj, expectedActions, done);
19+
if (this.flags.not) {
20+
assertions.toNotDispatchActions(this.obj, expectedActions, done);
21+
} else {
22+
assertions.toDispatchActions(this.obj, expectedActions, done);
23+
}
1624
}
1725
}
1826

test/expectjs/index.js

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

0 commit comments

Comments
 (0)