From 0d5231ff8702a4aa8f9d7de4505f53484a6630c3 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Tue, 14 Mar 2023 13:59:24 -0400 Subject: [PATCH] Fixed unit tests --- .../mobile-location-modal-questions.spec.js | 26 +++++++++++++++++ .../mobile-location-modal-questions.vue | 2 +- .../service-zip-modal-question.spec.js | 28 +++++++++++++++++++ .../service-zip-modal-question.vue | 1 + 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js index ab0ba6573..fbea693b9 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js @@ -93,6 +93,32 @@ const mockMixin = { }, }; +const mockGetPricedMobileFeePart = (mockServiceZipCode) => { + let mobileFeePart = {}; + + if (mockServiceZipCode === "43235") { + mobileFeePart = { + partNumber: "MOBILE FEE", + description: "MOBILE FEE", + partType: "FEE", + laborAmount: 49.99, + sellingPrice: 0, + kitPrice: 0, + }; + } + + return Promise.resolve(mobileFeePart); +}; + +jest.mock( + "@/layouts/service-location/helpers/service-location-helper/service-location-helper", + () => ({ + getPricedMobileFeePart: jest.fn((mockServiceZipCode) => { + return mockGetPricedMobileFeePart(mockServiceZipCode); + }), + }) +); + describe("mobile-location-modal-questions.vue", () => { it("Should copy the modelValue to the internalModel when the component is mounted", async () => { // Arrange diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue index 9bba10910..b4da4ddfa 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue @@ -64,7 +64,7 @@ import { getPricedMobileFeePart } from "@/layouts/service-location/helpers/servi export default { name: "mobile-location-modal-questions", - emits: ["update:modelValue"], // The component emits an event + emits: ["update:modelValue", "set-mobile-fee-part"], data() { return { internalModel: deepClone(this.modelValue), diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js index becbd9ebd..407e129cf 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js @@ -16,6 +16,32 @@ jest.mock("@/digital-components/modal/modal", () => ({ }, })); +const mockGetPricedMobileFeePart = (mockServiceZipCode) => { + let mobileFeePart = {}; + + if (mockServiceZipCode === "43235") { + mobileFeePart = { + partNumber: "MOBILE FEE", + description: "MOBILE FEE", + partType: "FEE", + laborAmount: 49.99, + sellingPrice: 0, + kitPrice: 0, + }; + } + + return Promise.resolve(mobileFeePart); +}; + +jest.mock( + "@/layouts/service-location/helpers/service-location-helper/service-location-helper", + () => ({ + getPricedMobileFeePart: jest.fn((mockServiceZipCode) => { + return mockGetPricedMobileFeePart(mockServiceZipCode); + }), + }) +); + const linkWidgetName = "linkWidgetName"; const modalWidgetName = "modalWidgetName"; @@ -126,6 +152,7 @@ describe("service-zip-modal-question.vue", () => { mixins: [mockMixin], props: { modelValue: serviceZipCodeQuestion, + mobileFeePart: {}, linkWidgetName: linkWidgetName, modalWidgetName: modalWidgetName, }, @@ -134,6 +161,7 @@ describe("service-zip-modal-question.vue", () => { // Act wrapper.vm.internalModel.zipCode = zip; + await wrapper.vm.setZipCode(); let expectedEmit = [[{ state: "OH", zipCode: "43235" }]]; diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue index 50041cec3..2c1e0e588 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue @@ -43,6 +43,7 @@ import { getPricedMobileFeePart } from "@/layouts/service-location/helpers/servi export default { name: "service-zip-modal-question", + emits: ["update:modelValue", "set-mobile-fee-part"], data() { return { internalModel: this.copyModel(this.modelValue),