From 86f0f0fb9444095097ec0273c72bdc11ea4df5ce Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 9 Jun 2023 09:36:21 -0400 Subject: [PATCH] Fixed unit tests --- src/layouts/molding-questions/molding-questions.spec.js | 3 ++- src/layouts/vehicle-parts/vehicle-parts.spec.js | 4 ++-- src/mixins/vehicle-questions-mixin.js | 2 +- src/store/store.spec.js | 5 ++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/layouts/molding-questions/molding-questions.spec.js b/src/layouts/molding-questions/molding-questions.spec.js index 13961df5a..9366540f6 100644 --- a/src/layouts/molding-questions/molding-questions.spec.js +++ b/src/layouts/molding-questions/molding-questions.spec.js @@ -109,7 +109,8 @@ store.getters = { damage: baseStoreGettersDamage, order: {}, }; -store.commit = jest.fn(); +//store.commit = jest.fn(); +store.dispatch = jest.fn(); afterEach(() => { // reset store after each test diff --git a/src/layouts/vehicle-parts/vehicle-parts.spec.js b/src/layouts/vehicle-parts/vehicle-parts.spec.js index 23ce3b88a..4d4287430 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.spec.js +++ b/src/layouts/vehicle-parts/vehicle-parts.spec.js @@ -481,7 +481,7 @@ describe("vehicle-parts.vue", () => { }, }); - wrapper.vm.$store.commit = jest.fn(); + wrapper.vm.dispatchStoreAction = jest.fn(); wrapper.setData({ selectedGlassParts: { "Rear-Stationary": { partNumber: "DB12209GTYN" } }, @@ -498,7 +498,7 @@ describe("vehicle-parts.vue", () => { await wrapper.vm.forwardButtonAction(); //Assert - expect(wrapper.vm.$store.commit).toHaveBeenCalled(); + expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalled(); // TODO KO UNCOMMENT FOR QUOTE PAGES RELEASE // expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith( diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 8f6cad4eb..4b05067ea 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -442,7 +442,7 @@ export default { const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions); // save to store lineItems.glassParts - self.$store.dispatch(storeActions.SAVE_GLASS_PARTS, collectedGlassParts); + self.dispatchStoreAction(storeActions.SAVE_GLASS_PARTS, collectedGlassParts, false); const payment = store.getters.payment; diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 6913c0527..262cb263a 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -961,7 +961,10 @@ describe("Actions", () => { it("saveGlassParts, should call mutation", () => { // Arrange - const context = state; + const context = { + state: state, + }; + const commit = jest.fn(); context.commit = commit;