@@ -63,10 +63,10 @@ const actions = actionsInjector({
63
63
})
64
64
65
65
// helper for testing action with expected mutations
66
- const testAction = (action , state , expectedMutations , done ) => {
66
+ const testAction = (action , args , state , expectedMutations , done ) => {
67
67
let count = 0
68
68
// mock dispatch
69
- const dispatch = (name , payload ) => {
69
+ const dispatch = (name , ... payload ) => {
70
70
const mutation = expectedMutations[count]
71
71
expect (mutation .name ).to .equal (name)
72
72
if (payload) {
@@ -77,16 +77,19 @@ const testAction = (action, state, expectedMutations, done) => {
77
77
done ()
78
78
}
79
79
}
80
- // call the action with mocked store
81
- action ({
82
- dispatch,
83
- state
84
- })
80
+ // call the action with mocked store and arguments
81
+ action ({dispatch, state}, ... args)
82
+
83
+ // check if no mutations should have been dispatched
84
+ if (count === 0 ) {
85
+ expect (expectedMutations .length ).to .equal (0 )
86
+ done ()
87
+ }
85
88
}
86
89
87
90
describe (' actions' , () => {
88
91
it (' getAllProducts' , done => {
89
- testAction (actions .getAllProducts , {}, [
92
+ testAction (actions .getAllProducts , [], {}, [
90
93
{ name: ' REQUEST_PRODUCTS' },
91
94
{ name: ' RECEIVE_PRODUCTS' , payload: [ /* mocked response */ ] }
92
95
], done)
0 commit comments