From 0c6d2cb6e87058095275a6eb605e028d9c342be7 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Thu, 9 Mar 2023 13:38:20 -0500 Subject: [PATCH] Got unit tests working again --- .../address-questions/address-questions.vue | 5 +++ .../object-cloning-helper.js | 0 .../object-cloning-helper.spec.js | 0 .../service-location-helper.js | 12 ++++-- .../service-location-helper.spec.js | 0 .../mobile-location-modal-questions.vue | 38 +++++++++---------- .../service-location/service-location.spec.js | 18 +++++---- .../service-location/service-location.vue | 35 ++++++++++------- 8 files changed, 64 insertions(+), 44 deletions(-) rename src/{helpers => layouts/service-location/helpers/object-cloning-helper}/object-cloning-helper.js (100%) rename src/{helpers => layouts/service-location/helpers/object-cloning-helper}/object-cloning-helper.spec.js (100%) rename src/{helpers => layouts/service-location/helpers/service-location-helper}/service-location-helper.js (69%) rename src/{helpers => layouts/service-location/helpers/service-location-helper}/service-location-helper.spec.js (100%) diff --git a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue index c37e596ef..1769961b7 100644 --- a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue +++ b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue @@ -22,6 +22,7 @@ aria-live="polite">
@@ -32,6 +33,7 @@
{ return Promise.resolve(mobileFeePart); }; -jest.mock("@/helpers/service-location-helper", () => ({ +jest.mock("@/layouts/service-location/helpers/service-location-helper/service-location-helper", () => ({ getPricedMobileFeePart: jest.fn((mockServiceZipCode) => { return mockGetPricedMobileFeePart(mockServiceZipCode); }), @@ -107,6 +107,9 @@ const mockMixin = { getTotalLineItemPrice: jest.fn((lineItem) => { return 49.99; }), + + onSubmit: jest.fn(), + onInvalidSubmit: jest.fn(), }, }; @@ -130,6 +133,9 @@ beforeEach(() => { state: "OH", }, }, + damage: { + isRepair: false + }, payment: { isInsurance: false, }, @@ -168,7 +174,7 @@ describe("service-location.vue", () => { ); // Assert - expect(wrapper.vm.mobileLocationQuestions.mobileFeePart).toStrictEqual(mobileFeePart); + expect(wrapper.vm.mobileFeePart).toStrictEqual(mobileFeePart); }); }); @@ -217,7 +223,9 @@ describe("service-location.vue", () => { describe("updating service zip", () => { test("updates the page model after providing the service zip code", () => { // Arrange - const { wrapper } = setupMocks({}); + const { wrapper } = setupMocks({ + mixins: [mockMixin] + }); wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn(); const newServiceZipCodeQuestion = { @@ -256,7 +264,6 @@ describe("service-location.vue", () => { zipCode: "43054", }, isVehicleProtected: true, - mobileFeePart: null, }; wrapper.vm.mobileLocationQuestions = mobileLocationQuestions; @@ -269,7 +276,6 @@ describe("service-location.vue", () => { zipCode: "61606", }, isVehicleProtected: null, - mobileFeePart: null, }; const serviceZipCodeComponent = wrapper.findComponent({ @@ -299,7 +305,6 @@ describe("service-location.vue", () => { zipCode: "", }, isVehicleProtected: null, - mobileFeePart: null, }; wrapper.vm.mobileLocationQuestions = mobileLocationQuestions; @@ -312,7 +317,6 @@ describe("service-location.vue", () => { zipCode: "43054", }, isVehicleProtected: true, - mobileFeePart: null, }; const mobileLocationComponent = wrapper.findComponent({ diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 3d1ea1a61..00017db80 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -37,7 +37,7 @@ import { Form } from "vee-validate"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; -import { getPricedMobileFeePart } from "@/helpers/service-location-helper"; +import { getPricedMobileFeePart } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; import store from "@/store"; export default { @@ -49,6 +49,7 @@ export default { city: this.getServiceCityFromStore(), state: this.getServiceStateFromStore(), zipCode: this.getServiceZipCodeFromStore(), + isVehicleProtected: null, isZipServiceableMobile: null, isZipServiceableInShop: null, mobileFeePart: null, @@ -59,7 +60,11 @@ export default { const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); const serviceZipCode = store.getters.order.serviceLocation.zipCode; - const mobileFeePartPromise = getPricedMobileFeePart(serviceZipCode); + const serviceType = store.getters.damage.isRepair ? "Repair" : "Replace"; + const parentAccountNumber = store.getters.payment.parentAccountNumber; + const billToAccountNumber = 0; + + const mobileFeePartPromise = getPricedMobileFeePart(serviceZipCode, serviceType, parentAccountNumber, billToAccountNumber); // Settle promises and get results const promiseResultMap = [ @@ -91,7 +96,7 @@ export default { }, set: function (newValue) { if (newValue.zipCode !== this.zipCode) { - this.resetMobileLocation(newValue.zipCode); + this.resetMobileLocation(newValue); } this.state = newValue.state; @@ -124,12 +129,11 @@ export default { }, methods: { arePagePrerequisitesValid() { - return true; - // return ( - // store.getters.lineItems.supportingItems !== null && - // store.getters.order.serviceLocation.zipCode !== null && - // store.getters.payment.isInsurance !== null - // ); + return ( + store.getters.lineItems.supportingItems !== null && + store.getters.order.serviceLocation.zipCode !== null && + store.getters.payment.isInsurance !== null + ); }, setData(mobileFeePart) { if (mobileFeePart) { @@ -149,19 +153,22 @@ export default { return store.getters.order.serviceLocation.zipCode; }, resetMobileFeePart(serviceZipCode) { - getPricedMobileFeePart(serviceZipCode).then((pricedMobileFeePart) => { + const serviceType = store.getters.damage.isRepair ? "Repair" : "Replace"; + const parentAccountNumber = store.getters.payment.parentAccountNumber; + const billToAccountNumber = 0; + + getPricedMobileFeePart(serviceZipCode, serviceType, parentAccountNumber, billToAccountNumber).then((pricedMobileFeePart) => { this.mobileFeePart = pricedMobileFeePart; }); }, - resetMobileLocation(updatedServiceZipCode) { + resetMobileLocation(updatedServiceZipCodeInfo) { this.streetAddress = ""; this.apartmentNumberOrBusinessName = ""; this.city = ""; + this.isVehicleProtected = null; - this.$refs.mobileLocationModalQuestions.resetComponent(); - - this.resetMobileFeePart(updatedServiceZipCode); + this.resetMobileFeePart(updatedServiceZipCodeInfo.zipCode); }, backButtonAction() { this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);