diff --git a/src/layouts/estimate/estimate.spec.js b/src/layouts/estimate/estimate.spec.js index 9278c24bf..3ea0babd1 100644 --- a/src/layouts/estimate/estimate.spec.js +++ b/src/layouts/estimate/estimate.spec.js @@ -215,23 +215,17 @@ describe("estimate.vue", () => { describe("estimate.vue", () => { test("should call forwardButtonAction if isLeadGen is true and form is valid", async () => { - // update store with isLeadGen as true - store.getters = { - isLeadGen: true, - leadGenEstimate: { - vinSelection: "decline", - }, - }; + store.commit(storeMutations.UPDATE_IS_LEAD_GEN, true); + store.commit(storeMutations.UPDATE_LEAD_GEN_VIN_SELECTION, "decline"); // Set up the component const { wrapper } = setupMocks({}); - baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true); wrapper.vm.forwardButtonAction = jest.fn(); + const nextFunction = jest.fn((c) => { c(wrapper.vm); }); - // Call the method that contains the if-else logic await estimate.beforeRouteEnter.call( wrapper.vm, @@ -239,9 +233,13 @@ describe("estimate.vue", () => { undefined, nextFunction ); - await nextTick(); + await wrapper.vm.$nextTick(); expect(nextFunction).toHaveBeenCalled(); + expect(baseMixin.methods.isFormValid).toHaveBeenCalled(); + expect(baseMixin.methods.isFormValid()).toBe(true); + await wrapper.vm.$nextTick(); + expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled(); }); }); @@ -287,7 +285,7 @@ function setupMocks({ const apiPromise = Promise.resolve({ cmsContent }); settleAllPromises.mockImplementation(() => apiPromise); fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - + baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true); const mountOptions = getMountOptions({ ...mountOptionsMockData, mixins: [baseMixin, mockMixin], diff --git a/src/layouts/quote/quote.spec.js b/src/layouts/quote/quote.spec.js index f7a158fc4..f6cb82858 100644 --- a/src/layouts/quote/quote.spec.js +++ b/src/layouts/quote/quote.spec.js @@ -705,6 +705,10 @@ describe("quote.vue", () => { ); await nextTick(); expect(nextFunction).toHaveBeenCalled(); + expect(baseMixin.methods.isFormValid).toHaveBeenCalled(); + expect(baseMixin.methods.isFormValid()).toBe(true); + await wrapper.vm.$nextTick(); + expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled(); }); }); @@ -714,6 +718,7 @@ function setupMocks({ customMountOptions }) { }); baseMixin.methods.hideFmgLoadingModal = jest.fn(); + baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true); mountOptions.global.mocks["$store"] = store; mountOptions["attachTo"] = document.body; const wrapper = shallowMount(quote, mountOptions);