diff options
-rw-r--r-- | spec/javascripts/helpers/vuex_action_helper.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/spec/javascripts/helpers/vuex_action_helper.js b/spec/javascripts/helpers/vuex_action_helper.js index 2d386fe1da5..8ba57956e47 100644 --- a/spec/javascripts/helpers/vuex_action_helper.js +++ b/spec/javascripts/helpers/vuex_action_helper.js @@ -26,8 +26,29 @@ export default (action, payload, state, expectedMutations, done) => { } }; + // mock dispatch + const dispatch = (type, dispatchPayload) => { + const mutation = expectedMutations[count]; + + try { + expect(mutation.type).to.equal(type); + + if (dispatchPayload) { + expect(mutation.payload).to.deep.equal(dispatchPayload); + } + } catch (error) { + done(error); + } + + count++; + + if (count >= expectedMutations.length) { + done(); + } + }; + // call the action with mocked store and arguments - action({ commit, state }, payload); + action({ commit, state, dispatch }, payload); // check if no mutations should have been dispatched if (expectedMutations.length === 0) { |