From e5bfae5811c4d3dc98d467d1b8f7cdb2d111cc7b Mon Sep 17 00:00:00 2001 From: CarlNation Date: Fri, 10 Feb 2023 16:16:27 -0500 Subject: [PATCH] CSR-1108 navigate to service-location from quote on cash --- src/layouts/quote/quote.spec.js | 130 ++++++++++++++++++ src/layouts/quote/quote.vue | 12 +- .../service-location/service-location.vue | 6 +- src/router/router-constants/fmgPage-values.js | 1 + .../router-constants/navigation-scenarios.js | 1 + src/router/router-constants/routing-table.js | 13 ++ 6 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 src/layouts/quote/quote.spec.js diff --git a/src/layouts/quote/quote.spec.js b/src/layouts/quote/quote.spec.js new file mode 100644 index 000000000..b233bc7e3 --- /dev/null +++ b/src/layouts/quote/quote.spec.js @@ -0,0 +1,130 @@ +import { shallowMount, flushPromises } from "@vue/test-utils"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import { applicationConfig } from "@/constants/application-config"; +import quote from "@/layouts/quote/quote.vue"; +import store from "@/store"; +import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-helper"; + +jest.mock("@/store", () => ({ + commit: jest.fn(), + dispatch: jest.fn() +})); + +// Mock our module for promises. +jest.mock("@/helpers/layout-helper.js", () => ({ + settleAllPromises: jest.fn(), +})); + +// Mock fetchCmsContentForPage +jest.mock("@/helpers/cms-content-helper", () => ({ + fetchCmsContentForPage: jest.fn(), +})); + +jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({ + navigateToHeritageFunnel: jest.fn(), +})); + +jest.mock( + "@/store", + () => { + return {}; + }, + { virtual: true } +); + + +store.getters = { + order: { + accountNumber: applicationConfig.CASH_ACCOUNT_NUMBER, + }, + payment: { + insuranceCoverage: {}, + isInsurance: false, + } +}; + +afterEach(() => { + // reset store after each test + store.getters = { + order: { + accountNumber: applicationConfig.CASH_ACCOUNT_NUMBER, + }, + payment: { + insuranceCoverage: {}, + isInsurance: false, + } + }; +}); + +describe("quote.vue", () => { + test("IsInsurance false should navigateWithSaving", async () => { + //Arrange + const { wrapper } = setupMocks({ + customMountOptions: { + router: { + navigateWithSaving: jest.fn(), + }, + route: { quote } + }, + }); + + store.getters.payment = { + insuranceCoverage: {}, + isInsurance : false + }; + + wrapper.vm.dispatchStoreAction = jest.fn(() => { + return { + data: [], + }; + }); + + //Act + await wrapper.vm.forwardButtonAction(); + + //Assert + expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled(); + }); + + test("IsInsurance true should navigateToHeritageFunnel", async () => { + //Arrange + const { wrapper } = setupMocks({ + customMountOptions: { + router: { + navigateWithSaving: jest.fn(), + }, + route: { quote } + }, + }); + + store.getters.payment = { + insuranceCoverage: {}, + isInsurance : true + }; + + wrapper.vm.dispatchStoreAction = jest.fn(() => { + return { + data: [], + }; + }); + + //Act + await wrapper.vm.forwardButtonAction(); + + //Assert + expect(navigateToHeritage.navigateToHeritageFunnel).toHaveBeenCalled(); + }); +}); + + +function setupMocks({ customMountOptions }) { + const mountOptions = getMountOptions({ + ...customMountOptions, + }); + + mountOptions.global.mocks["$store"] = store; + mountOptions["attachTo"] = document.body; + + const wrapper = shallowMount(quote, mountOptions); + return { wrapper }; +} diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 21f5753bb..853cd2abf 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -1,4 +1,3 @@ -digital