From 62550ab6a07510377e9c88277b1b5d2c3f9be682 Mon Sep 17 00:00:00 2001 From: Bryan Mauger Date: Thu, 4 Aug 2022 13:23:34 -0400 Subject: [PATCH] Update unit test. --- .../vin-information/vin-information.spec.js | 10 ++++- .../vin-information/vin-information.vue | 20 ---------- src/layouts/vin-lookup/vin-lookup.vue | 38 +++++++++---------- 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/src/layouts/vin-lookup/vin-information/vin-information.spec.js b/src/layouts/vin-lookup/vin-information/vin-information.spec.js index b80daf9ef..7ffdeedf8 100644 --- a/src/layouts/vin-lookup/vin-information/vin-information.spec.js +++ b/src/layouts/vin-lookup/vin-information/vin-information.spec.js @@ -4,7 +4,9 @@ import vinInformation from "@/layouts/vin-lookup/vin-information/vin-information describe("vinInformation.vue", () => { it("Should return input class active if isActive is true", async () => { // Act - const wrapper = shallowMount(vinInformation); + const wrapper = shallowMount(vinInformation, { + mixins: [mockMixin] + }); await wrapper.setData({ isActive: true, @@ -16,3 +18,9 @@ describe("vinInformation.vue", () => { expect(wrapper.vm.isActive).toEqual(false); }); }); + +const mockMixin = { + methods: { + getCmsContent: jest.fn() + } +} diff --git a/src/layouts/vin-lookup/vin-information/vin-information.vue b/src/layouts/vin-lookup/vin-information/vin-information.vue index a4c2fcdb1..50194ee7b 100644 --- a/src/layouts/vin-lookup/vin-information/vin-information.vue +++ b/src/layouts/vin-lookup/vin-information/vin-information.vue @@ -18,29 +18,9 @@ import textLink from "@/ux-components/text-link/text-link"; //Supporting files -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; export default { name: "vinInformation", - async beforeRouteEnter(to, from, next) { - // Call APIs - const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); - - // Settle promises and get results - const promiseResultMap = [ - { - resultKey: "cmsContent", - promise: cmsContentPromise, - }, - ]; - - const resultMap = await settleAllPromises(promiseResultMap); - - // Call the "next" function to complete the transition to this page. - next((vm) => { - vm.setCmsContent(resultMap.cmsContent); - }); - }, components: { textLink, }, diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 4ba6a9fe9..84c17cfd9 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -56,19 +56,19 @@ /> - + { this.pushEventToGA( this.$route.query[this.queryStrings.FMG_PAGE], @@ -243,9 +243,9 @@ export default { if (this.serviceZipCode && !isZipValid) { this.displayInvalidZipAlert = true; return this.$refs.funnelFooter.removeLoader(); - } + } this.displayInvalidZipAlert = false; - + // If either lookup fails, remove the loader and stop processing the page. if (!resultMap.vehicleLookupResponse || !resultMap.serviceZipValidationResponse.isServiceable) { // If the vehicle result is undefined, the vin entered was invalid. @@ -270,7 +270,7 @@ export default { this.previouslyEnteredCarId = resultMap.vehicleLookupResponse.carId; this.customAlertData.vehicleInfo = resultMap.vehicleLookupResponse; this.displayMatchedDifferentVehicleAlert = true; - + this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(resultMap.vehicleLookupResponse.carId); // Update button "Continue with..." @@ -292,12 +292,12 @@ export default { }, false); return await this.navigateForward(); - + } // If a VIN has already been found. Validate the Service Zip (in case of changes) const zipValidationResponse = await this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.serviceZipCode}); - + // Check if Service Zip entered is serviceable if (zipValidationResponse.data.isServiceable) { // If the Service Zip entered is serviceable then save the Zip Info and Email Address and navigate forward @@ -379,8 +379,8 @@ export default { } else { return 'XXXXXXXXXXXXXXXXX'; - } - }, + } + }, }, watch: { vin() { @@ -397,10 +397,10 @@ export default { vehicleBanner, funnelSubHeader, textboxQuestion, - alert, + alert, vinInformation, loadingModal, - Form, + Form, }, };