diff --git a/src/layouts/vehicle-make/make-question/make-question.spec.js b/src/layouts/vehicle-make/make-question/make-question.spec.js deleted file mode 100644 index af0063df..00000000 --- a/src/layouts/vehicle-make/make-question/make-question.spec.js +++ /dev/null @@ -1,70 +0,0 @@ -import makeQuestion from "@/layouts/vehicle-make/make-question/make-question"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { useMainStore } from "@/store"; - - -describe("make-question.vue", () => { - - test("Data from store api are used as radio question answers.", async () => { - //Arrange - const { wrapper, cmsContent } = setupMocks({ - dataFromStoreApi: ["honda", "ford", "dodge"], - }); - - //Act - const initialData = makeQuestion.methods.loadInitialData.call(wrapper.vm); - makeQuestion.methods.initializeComponent.call( - wrapper.vm, - initialData - ); - - //Assert - const buttonQuestionComponent = await wrapper.findComponent({ - name: "buttonQuestion", - }); - expect(buttonQuestionComponent.attributes("answers")).toBe( - "honda,ford,dodge" - ); - }); - - test("Selected make is emitted upon selection.", async () => { - //Arrange - const { wrapper } = setupMocks({ modelValueProp: "honda" }); - const makeToSelect = "ford"; - - //Act - wrapper.setValue({ selectedMake: makeToSelect }); - await wrapper.vm.$nextTick(); - - //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual([ - { selectedMake: "ford" }, - ]); - }); - -}); - -function setupMocks({ - modelValueProp = "1900", - cmsQuestionText = "CMS text goes here", - dataFromStoreApi = [], -}) { - //Mock store - const mountOptions = getMountOptions(); - - const store = useMainStore(); - store.getVehicleMakes = jest.fn(() => dataFromStoreApi); - - - mountOptions.propsData = { - modelValue: modelValueProp, - }; - const wrapper = shallowMount(makeQuestion, mountOptions); - - //Mock CMS content - const cmsContent = { - QuestionText: cmsQuestionText, - }; - return { wrapper, cmsContent }; -} diff --git a/src/layouts/vehicle-make/make-question/make-question.vue b/src/layouts/vehicle-make/make-question/make-question.vue deleted file mode 100644 index 3bb1a818..00000000 --- a/src/layouts/vehicle-make/make-question/make-question.vue +++ /dev/null @@ -1,56 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/layouts/vehicle-make/vehicle-make.spec.js b/src/layouts/vehicle-make/vehicle-make.spec.js deleted file mode 100644 index 3de29b6f..00000000 --- a/src/layouts/vehicle-make/vehicle-make.spec.js +++ /dev/null @@ -1,154 +0,0 @@ -// Supporting Files -import { shallowMount } from "@vue/test-utils"; -import { settleAllPromises } from "@/helpers/layout-helper.js"; -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; -import baseMixin from "@/mixins/base-mixin.js"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { nextTick } from "vue"; -import { useMainStore } from "@/store"; -import { applicationConfig } from "@/constants/application-config"; - -// Components -import vehicleMake from "@/layouts/vehicle-make/vehicle-make.vue"; -import makeQuestion from "@/layouts/vehicle-make/make-question/make-question"; - -// Mock fetchCmsContentForPage -jest.mock("@/helpers/cms-content-helper", () => ({ - fetchCmsContentForPage: jest.fn(), -})); - -// Mock our module for promises. -jest.mock("@/helpers/layout-helper.js", () => ({ - settleAllPromises: jest.fn(), -})); - -describe("vehicle-make.vue", () => { - - test("Make question component is initized with api data", async () => { - //Arrange - const makeQuestionInitialData = ["honda", "ford", "dodge"]; - const { wrapper, apiPromise } = setupMocks({ - makeQuestionInitialData: makeQuestionInitialData, - }); - - //Act - vehicleMake.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-make" } }, - undefined, - (c) => c(wrapper.vm) - ); - - //Assert - return apiPromise.finally(() => { - try { - expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith( - makeQuestionInitialData - ); - } - catch (e) { - throw e - } - }); - - }); - - test("BackButtonAction triggers a router.navigate change", async () => { - //Arrange - const { wrapper, apiPromise } = setupMocks({ - pageHeaderWidgetHeaderText: "Select a make to get started", - mountOptionsMockData: { - router: { - navigate: jest.fn(), - }, - }, - }); - - //Act - vehicleMake.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-make" } }, - undefined, - (c) => c(wrapper.vm) - ); - wrapper.vm.backButtonAction(); - await nextTick(); - - //Assert - return apiPromise.finally(() => { - try { - expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); - } - catch (e) { - throw e - } - }); - - }); - - test("Year set, arePagePrerequisitesValid should be true ", () => { - //Arrange - const { wrapper } = setupMocks({}); - useMainStore().order.vehicle.year = 2001; - - //Act - vehicleMake.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-make" } }, - undefined, - (c) => c(wrapper.vm) - ); - - let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); - - //Assert - expect(arePagePrerequisitesValid).toBe(true); - }); - -}); - -function setupMocks({ - vehicleMakeQuestionCmsContent = {}, - makeQuestionInitialData = {}, - pageHeaderWidgetHeaderText = {}, - mountOptionsMockData = {}, -}) { - //Mock api responses - const apiResponses = { - cmsContent: { - SiteSubHeaderWidget: pageHeaderWidgetHeaderText, - VehicleMakeQuestion: vehicleMakeQuestionCmsContent, - VehicleBannerWidget: { - GenericVehicleImage: - `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/blurred-image.jpg`, - }, - SiteHeaderWidget: { - LogoImage: - `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/logos/insuranceLogo.jpg`, - }, - }, - makeQuestionInitialData: makeQuestionInitialData, - }; - - const apiPromise = Promise.resolve(apiResponses); - - settleAllPromises.mockImplementation(() => apiPromise); - fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - - //Mock make question methods - makeQuestion.methods = { - loadInitialData: jest.fn(), - initializeComponent: jest.fn(), - }; - - const mountOptions = getMountOptions(mountOptionsMockData); - const wrapper = shallowMount(vehicleMake, mountOptions); - - const makeQuestionWrapper = wrapper.findComponent({ name: "makeQuestion" }); - makeQuestionWrapper.vm.initializeComponent = - makeQuestion.methods.initializeComponent; - - wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; - - return { wrapper, apiPromise }; -} diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue deleted file mode 100644 index c76151cc..00000000 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ /dev/null @@ -1,102 +0,0 @@ - - - diff --git a/src/layouts/vehicle-model/model-question/model-question.spec.js b/src/layouts/vehicle-model/model-question/model-question.spec.js deleted file mode 100644 index c681ee85..00000000 --- a/src/layouts/vehicle-model/model-question/model-question.spec.js +++ /dev/null @@ -1,71 +0,0 @@ -import modelQuestion from "@/layouts/vehicle-model/model-question/model-question"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { useMainStore } from "@/store"; - -describe("model-question.vue", () => { - test("Selected model is emitted upon selection.", async () => { - //Arrange - const { wrapper } = setupMocks({ modelValueProp: "Accord" }); - const modelToSelect = "Civic"; - - //Act - wrapper.setValue({ selectedModel: modelToSelect }); - await wrapper.vm.$nextTick(); - - //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual([ - { selectedModel: "Civic" }, - ]); - }); -}); - - -describe("model-question.vue", () => { - test("Data from store api are used as radio question answers.", async () => { - //Arrange - const { wrapper, cmsContent } = setupMocks({ - dataFromStoreApi: ["accord", "civic", "insight"], - }); - - //Act - const initialData = modelQuestion.methods.loadInitialData.call(wrapper.vm); - modelQuestion.methods.initializeComponent.call( - wrapper.vm, - initialData - ); - - //Assert - const buttonQuestionComponent = await wrapper.findComponent({ - name: "buttonQuestion", - }); - expect(buttonQuestionComponent.attributes("answers")).toBe( - "accord,civic,insight" - ); - }); -}); - -function setupMocks({ - modelValueProp = "1900", - cmsQuestionText = "CMS text goes here", - dataFromStoreApi = [], -}) { - //Mock store - const store = useMainStore(); - store.getVehicleModels = jest.fn(() => dataFromStoreApi); - - const mountOptions = getMountOptions(); - - //Mock props - mountOptions.propsData = { - modelValue: modelValueProp, - }; - - const wrapper = shallowMount(modelQuestion, mountOptions); - - //Mock CMS content - const cmsContent = { - QuestionText: cmsQuestionText, - }; - return { wrapper, cmsContent }; -} diff --git a/src/layouts/vehicle-model/model-question/model-question.vue b/src/layouts/vehicle-model/model-question/model-question.vue deleted file mode 100644 index 595fcb4f..00000000 --- a/src/layouts/vehicle-model/model-question/model-question.vue +++ /dev/null @@ -1,56 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/layouts/vehicle-model/vehicle-model.spec.js b/src/layouts/vehicle-model/vehicle-model.spec.js deleted file mode 100644 index c727358d..00000000 --- a/src/layouts/vehicle-model/vehicle-model.spec.js +++ /dev/null @@ -1,152 +0,0 @@ -// Components -import vehicleModel from "@/layouts/vehicle-model/vehicle-model.vue"; -import modelQuestion from "@/layouts/vehicle-model/model-question/model-question"; - -// Supporting files - -import { shallowMount } from "@vue/test-utils"; -import { settleAllPromises } from "@/helpers/layout-helper.js"; -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; -import baseMixin from "@/mixins/base-mixin.js"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { nextTick } from "vue"; -import { useMainStore } from "@/store"; -import { applicationConfig } from "@/constants/application-config"; - -// 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(), -})); - -describe("vehicle-model.vue", () => { - test("Model question component is initized with api data", async () => { - //Arange - const modelQuestionInitialData = ["accord", "civic", "insight"]; - const { wrapper, apiPromise } = setupMocks({ - modelQuestionInitialData: modelQuestionInitialData, - }); - //Act - vehicleModel.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-model" } }, - undefined, - (c) => c(wrapper.vm) - ); - - //Assert - return apiPromise.finally(() => { - try { - expect(modelQuestion.methods.initializeComponent).toHaveBeenCalledWith( - modelQuestionInitialData - ); - } - catch (e) { - throw e - } - }); - }); -}); - -describe("vehicle-model.vue", () => { - test("BackButtonAction triggers a router.navigate change", async () => { - //Arrange - const { wrapper, apiPromise } = setupMocks({ - pageHeaderWidgetHeaderText: "Select a model to get started", - mountOptionsMockData: { - router: { - navigate: jest.fn(), - }, - }, - }); - //Act - vehicleModel.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-model" } }, - undefined, - (c) => c(wrapper.vm) - ); - wrapper.vm.backButtonAction(); - await nextTick(); - - //Assert - return apiPromise.finally(() => { - try { - expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); - } - catch (e) { - throw e - } - }); - - }); -}); - -describe("vehicle-model.vue", () => { - test("Make set, arePagePrerequisitesValid should be true ", () => { - //Arrange - const { wrapper } = setupMocks({}); - useMainStore().order.vehicle.make = "Honda"; - - //Act - vehicleModel.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-model" } }, - undefined, - (c) => c(wrapper.vm) - ); - - let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); - - //Assert - expect(arePagePrerequisitesValid).toBe(true); - }); -}); - - -function setupMocks({ - buttonQuestionContent = {}, - modelQuestionInitialData = {}, - pageHeaderWidgetHeaderText = {}, - mountOptionsMockData = {}, -}) { - //Mock api responses - const apiResponses = { - cmsContent: { - SiteSubHeaderWidget: pageHeaderWidgetHeaderText, - VehicleModelQuestion: buttonQuestionContent, - VehicleBannerWidget: { - GenericVehicleImage: - `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/blurred-image.jpg`, - }, - SiteHeaderWidget: { - LogoImage: - `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/logos/insuranceLogo.jpg`, - }, - }, - modelQuestionInitialData: modelQuestionInitialData, - }; - const apiPromise = Promise.resolve(apiResponses); - - settleAllPromises.mockImplementation(() => apiPromise); - fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - - //Mock model question methods - modelQuestion.methods = { - loadInitialData: jest.fn(), - initializeComponent: jest.fn(), - }; - const mountOptions = getMountOptions(mountOptionsMockData); - const wrapper = shallowMount(vehicleModel, mountOptions); - wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; - - const modelQuestionWrapper = wrapper.findComponent({ name: "modelQuestion" }); - modelQuestionWrapper.vm.initializeComponent = - modelQuestion.methods.initializeComponent; - - return { wrapper, apiPromise }; -} diff --git a/src/layouts/vehicle-model/vehicle-model.vue b/src/layouts/vehicle-model/vehicle-model.vue deleted file mode 100644 index ca9f8c8c..00000000 --- a/src/layouts/vehicle-model/vehicle-model.vue +++ /dev/null @@ -1,111 +0,0 @@ - - - diff --git a/src/layouts/vehicle-style/style-question/style-question.spec.js b/src/layouts/vehicle-style/style-question/style-question.spec.js deleted file mode 100644 index bbb2bd70..00000000 --- a/src/layouts/vehicle-style/style-question/style-question.spec.js +++ /dev/null @@ -1,62 +0,0 @@ -import styleQuestion from "@/layouts/vehicle-style/style-question/style-question"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { useMainStore } from "@/store"; - - -describe("style-question.vue", () => { - - test("Data from store api are used as radio question answers.", async () => { - //Arrange - const { wrapper, cmsContent } = setupMocks({ - dataFromStoreApi: ["2 Door", "4 Door"], - }); - - //Act - const initialData = styleQuestion.methods.loadInitialData.call(wrapper.vm); - styleQuestion.methods.initializeComponent.call(wrapper.vm, initialData); - - //Assert - const buttonQuestionComponent = await wrapper.findComponent({ - name: "buttonQuestion", - }); - expect(buttonQuestionComponent.attributes("answers")).toBe("2 Door,4 Door"); - }); - - test("Selected style is emitted upon selection.", async () => { - //Arrange - const { wrapper } = setupMocks({ modelValueProp: "2 Door" }); - const styleToSelect = "4 Door"; - - //Act - wrapper.setValue({ selectedStyle: styleToSelect }); - await wrapper.vm.$nextTick(); - - //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ selectedStyle: "4 Door" }]); - }); - -}); - -function setupMocks({ - modelValueProp = "1900", - cmsQuestionText = "CMS text goes here", - dataFromStoreApi = [], -}) { - //Mock store - const mountOptions = getMountOptions(); - - const store = useMainStore(); - store.getVehicleStyles = jest.fn(() => dataFromStoreApi); - - mountOptions.propsData = { - modelValue: modelValueProp, - }; - const wrapper = shallowMount(styleQuestion, mountOptions); - - //Mock CMS content - const cmsContent = { - QuestionText: cmsQuestionText, - }; - return { wrapper, cmsContent }; -} diff --git a/src/layouts/vehicle-style/style-question/style-question.vue b/src/layouts/vehicle-style/style-question/style-question.vue deleted file mode 100644 index 84e4d19a..00000000 --- a/src/layouts/vehicle-style/style-question/style-question.vue +++ /dev/null @@ -1,54 +0,0 @@ - - - diff --git a/src/layouts/vehicle-style/vehicle-style.spec.js b/src/layouts/vehicle-style/vehicle-style.spec.js deleted file mode 100644 index 5e74b541..00000000 --- a/src/layouts/vehicle-style/vehicle-style.spec.js +++ /dev/null @@ -1,211 +0,0 @@ -// Supporting files -import { shallowMount } from "@vue/test-utils"; -import { settleAllPromises } from "@/helpers/layout-helper.js"; -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; -import baseMixin from "@/mixins/base-mixin.js"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { nextTick } from "vue"; -import { useMainStore } from "@/store"; -import router from "@/router"; -import { applicationConfig } from "@/constants/application-config"; - -// Components -import vehicleStyle from "@/layouts/vehicle-style/vehicle-style.vue"; -import styleQuestion from "@/layouts/vehicle-style/style-question/style-question"; - -jest.mock("@/router", () => ({ - overrideNavigation: 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(), -})); - -describe("vehicle-style.vue", () => { - - test("Style question component is initized with api data", async () => { - //Arrange - const styleQuestionInitialData = ["2 Door", "4 Door"]; - const { wrapper, apiPromise } = setupMocks({ - styleQuestionInitialData: styleQuestionInitialData, - }); - - //Act - vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - - //Assert - return apiPromise.finally(() => { - try { - expect(styleQuestion.methods.initializeComponent).toHaveBeenCalledWith( - styleQuestionInitialData - ); - } - catch (e) { - throw e - } - }); - }); - - test("BackButtonAction triggers a router.navigate change", async () => { - //Arrange - const { wrapper, apiPromise } = setupMocks({ - pageHeaderWidgetHeaderText: "Select a style to get started", - mountOptionsMockData: { - router: { - navigate: jest.fn(), - }, - }, - }); - - //Act - vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - wrapper.vm.backButtonAction(); - await nextTick(); - - //Assert - return apiPromise.finally(() => { - try { - expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); - } - catch (e) { - throw e - } - }); - }); - - test("Model set, arePagePrerequisitesValid should be true ", () => { - //Arrange - const { wrapper } = setupMocks({ }); - - useMainStore().order.vehicle = { year: 2011, make: "ford", model: "mustang", style: null } - - //Act - const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); - - //Assert - expect(arePagePrerequisitesValid).toBe(true); - }); - - test("there is only one vehicle style => autoselect and move to vehicle damage", async () => { - //Arrange - const { wrapper } = setupMocks({ - styleQuestionInitialData: ["2 door sedan"], - }); - - useMainStore().applicationUser.pageData = { - "part-questions": null, - "vehicle-make": {}, - "vehicle-model": {}, - "vehicle-style": {}, - } - - useMainStore().updateVehicleStyle = jest.fn(); - useMainStore().setVehicle = jest.fn().mockReturnValue(Promise.resolve()) - - // Act - await vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - - // Assert - expect(useMainStore().updateVehicleStyle).toHaveBeenCalledWith("2 door sedan"); - expect(router.overrideNavigation).toHaveBeenCalled(); - }); - - - test("there is only one vehicle style and vehicle-damage was visited => don't autoselect or move to vehicle damage", async () => { - //Arrange - const { wrapper } = setupMocks({ - styleQuestionInitialData: ["2 door sedan"], - }); - - useMainStore().updateVehicleStyle = jest.fn(); - useMainStore().setVehicle = jest.fn().mockReturnValue(Promise.resolve()) - - useMainStore().applicationUser.pageData = { - "part-questions": null, - "vehicle-make": {}, - "vehicle-model": {}, - "vehicle-style": {}, - "vehicle-damage": {}, - } - - // Act - await vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - - // Assert - expect(useMainStore().updateVehicleStyle).not.toHaveBeenCalledWith("2 door sedan"); - expect(router.overrideNavigation).toHaveBeenCalled(); - }); -}); - -function setupMocks({ - vehicleStyleQuestionCmsContent = {}, - styleQuestionInitialData = {}, - pageHeaderWidgetHeaderText = {}, - mountOptionsMockData = {}, -}) { - //Mock api responses - const apiResponses = { - cmsContent: { - SiteSubHeaderWidget: pageHeaderWidgetHeaderText, - VehicleStyleQuestion: vehicleStyleQuestionCmsContent, - VehicleBannerWidget: { - GenericVehicleImage: - `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/blurred-image.jpg`, - }, - SiteHeaderWidget: { - LogoImage: - `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/logos/insuranceLogo.jpg`, - }, - }, - styleQuestionInitialData: styleQuestionInitialData, - }; - - const apiPromise = Promise.resolve(apiResponses); - - settleAllPromises.mockImplementation(() => apiPromise); - fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - - //Mock style question methods - styleQuestion.methods = { - loadInitialData: jest.fn(), - initializeComponent: jest.fn(), - }; - - - const mountOptions = getMountOptions(mountOptionsMockData); - const wrapper = shallowMount(vehicleStyle, mountOptions); - - const styleQuestionWrapper = wrapper.findComponent({ name: "styleQuestion" }); - styleQuestionWrapper.vm.initializeComponent = - styleQuestion.methods.initializeComponent; - - wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; - - return { wrapper, apiPromise }; -} diff --git a/src/layouts/vehicle-style/vehicle-style.vue b/src/layouts/vehicle-style/vehicle-style.vue deleted file mode 100644 index 3a85adea..00000000 --- a/src/layouts/vehicle-style/vehicle-style.vue +++ /dev/null @@ -1,124 +0,0 @@ - - - diff --git a/src/layouts/vehicle-year/vehicle-year.spec.js b/src/layouts/vehicle-year/vehicle-year.spec.js deleted file mode 100644 index 5b054709..00000000 --- a/src/layouts/vehicle-year/vehicle-year.spec.js +++ /dev/null @@ -1,115 +0,0 @@ -import { shallowMount } from "@vue/test-utils"; -import { settleAllPromises } from "@/helpers/layout-helper.js"; -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; -import vehicleYear from "@/layouts/vehicle-year/vehicle-year.vue"; -import yearQuestion from "@/layouts/vehicle-year/year-question/year-question"; -import baseMixin from "@/mixins/base-mixin.js"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { nextTick } from "vue"; -import { applicationConfig } from "@/constants/application-config"; - - -// 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(), -})); - -describe("vehicle-year.vue", () => { - test("Year question component is initized with api data", async() => { - //Arrange - const yearQuestionInitialData = ["2023", "2022", "2021"]; - const { wrapper, apiPromise } = setupMocks({ - yearQuestionInitialData: yearQuestionInitialData, - }); - - - //Act - vehicleYear.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-year" } }, - undefined, - (c) => c(wrapper.vm) - ); - - //Assert - return apiPromise.finally(() => { - try { - expect(yearQuestion.methods.initializeComponent).toHaveBeenCalledWith( - yearQuestionInitialData - ); - } - catch (e) { - throw e - } - }); - - }); -}); - -describe("vehicle-year.vue", () => { - test("arePagePrerequisitesValid should be true ", () => { - //Arrange - const { wrapper } = setupMocks({}); - - //Act - vehicleYear.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "vehicle-make" } }, - undefined, - (c) => c(wrapper.vm) - ); - - let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); - - //Assert - expect(arePagePrerequisitesValid).toBe(true); - }); -}); - -function setupMocks({ - vehicleYearQuestionCmsContent = {}, - yearQuestionInitialData = {}, - pageHeaderWidgetHeaderText = {}, - mountOptionsMockData = {}, -}) { - //Mock api responses - const apiResponses = { - cmsContent: { - SiteSubHeaderWidget: { HeaderText: pageHeaderWidgetHeaderText }, - VehicleYearQuestion: vehicleYearQuestionCmsContent, - VehicleBannerWidget: { - GenericVehicleImage: - `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/blurred-image.jpg`, - }, - SiteHeaderWidget: { - LogoImage: - `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/logos/insuranceLogo.jpg`, - }, - }, - yearQuestionInitialData: yearQuestionInitialData, - }; - const apiPromise = Promise.resolve(apiResponses); - - settleAllPromises.mockImplementation(() => apiPromise); - fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - - //Mock year question methods - yearQuestion.methods = { - loadInitialData: jest.fn(), - initializeComponent: jest.fn(), - }; - - const mountOptions = getMountOptions(mountOptionsMockData); - const wrapper = shallowMount(vehicleYear, mountOptions); - - const yearQuestionWrapper = wrapper.findComponent({ name: "yearQuestion" }); - yearQuestionWrapper.vm.initializeComponent = yearQuestion.methods.initializeComponent; - wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; - - return { wrapper, apiPromise }; -} diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue deleted file mode 100644 index 4fd9c626..00000000 --- a/src/layouts/vehicle-year/vehicle-year.vue +++ /dev/null @@ -1,101 +0,0 @@ - - - diff --git a/src/layouts/vehicle-year/year-question/year-question.spec.js b/src/layouts/vehicle-year/year-question/year-question.spec.js deleted file mode 100644 index 39138d8f..00000000 --- a/src/layouts/vehicle-year/year-question/year-question.spec.js +++ /dev/null @@ -1,70 +0,0 @@ -import yearQuestion from "@/layouts/vehicle-year/year-question/year-question"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { useMainStore } from "@/store"; - -describe("year-question.vue", () => { - test("Selected year is emitted upon selection.", async () => { - //Arrange - const { wrapper } = setupMocks({ modelValueProp: 2020 }); - const yearToSelect = 2021; - - //Act - wrapper.setValue({ modelValue: yearToSelect }); - await wrapper.vm.$nextTick(); - - //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual([ - { modelValue: 2021 }, - ]); - }); -}); - -describe("year-question.vue", () => { - test("Data from store api are used as radio question answers.", async () => { - //Arrange - const { wrapper, cmsContent } = setupMocks({ - dataFromStoreApi: [2023, 2022, 2021], - }); - - //Act - const initialData = yearQuestion.methods.loadInitialData.call(wrapper.vm); - yearQuestion.methods.initializeComponent.call( - wrapper.vm, - initialData - ); - - //Assert - const buttonQuestionComponent = await wrapper.findComponent({ - name: "buttonQuestion", - }); - expect(buttonQuestionComponent.attributes("answers")).toBe( - "2023,2022,2021" - ); - }); -}); - - -function setupMocks({ - modelValueProp = 1900, - cmsQuestionText = "CMS text goes here", - dataFromStoreApi = [], -}) { - - const mountOptions = getMountOptions(); - - const store = useMainStore(); - store.getVehicleYears = jest.fn(() => dataFromStoreApi); - //Mock props - mountOptions.propsData = { - modelValue: modelValueProp, - }; - - const wrapper = shallowMount(yearQuestion, mountOptions); - - //Mock CMS content - const cmsContent = { - QuestionText: cmsQuestionText, - }; - return { wrapper, cmsContent }; -} diff --git a/src/layouts/vehicle-year/year-question/year-question.vue b/src/layouts/vehicle-year/year-question/year-question.vue deleted file mode 100644 index 540740eb..00000000 --- a/src/layouts/vehicle-year/year-question/year-question.vue +++ /dev/null @@ -1,56 +0,0 @@ - - - - \ No newline at end of file