From fbbb92c855da40777f1a53aebd67340957ce7423 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Thu, 23 Feb 2023 08:51:07 -0500 Subject: [PATCH] Added .spec file for mobile-location-question --- .../mobile-location-modal-questions.spec.js | 98 +++++++++++++++++++ .../vehicle-protected-question.spec.js | 27 +++-- 2 files changed, 111 insertions(+), 14 deletions(-) create mode 100644 src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js 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 new file mode 100644 index 000000000..9dde622fe --- /dev/null +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js @@ -0,0 +1,98 @@ +import { mount, shallowMount } from "@vue/test-utils"; +import mobileLocationModalQuestions from "./mobile-location-modal-questions"; +import crypto from "crypto"; +global.crypto = crypto; + +// const linkWidgetName = "linkWidgetName"; +// const modalWidgetName = "modalWidgetName"; +// const mobileFeeDisclaimerWidgetName = "MobileFeeDisclaimerWidget"; +// const workspaceRequirementsWidgetName = "WorkspaceRequirementsWidget"; + +// const mockLinkCmsContent = { +// BodyText: "Sample link body text here.", +// }; + +// const mockModalCmsContent = { +// FooterText: "Sample modal footer text here.", +// }; + +// const mockMobileFeeCmsContent = { +// Text: "This is the price {custom:mobileFee}", +// }; + +const mockMixin = { + methods: { + getCmsContent: jest.fn((widgetName, cmsFieldName) => { + if (widgetName === linkWidgetName) { + return mockLinkCmsContent[cmsFieldName]; + } + + if (widgetName === modalWidgetName) { + return mockModalCmsContent[cmsFieldName]; + } + + if (widgetName === mobileFeeDisclaimerWidgetName) { + return mockMobileFeeCmsContent[cmsFieldName]; + } + + return null; + }), + + getZipCodeData: jest.fn((zip) => { + if (zip === "43235") { + return { + containsMilitaryBase: false, + isServiceable: true, + isValid: true, + state: "OH", + zipCodeCtu: "01820", + }; + } + + if (zip === "61606") { + return { + containsMilitaryBase: false, + isServiceable: true, + isValid: true, + state: "IL", + zipCodeCtu: "01526", + }; + } + + return { + containsMilitaryBase: false, + isServiceable: false, + isValid: false, + state: null, + zipCodeCtu: null, + }; + }), + }, +}; + +describe("mobile-location-modal-questions.vue", () => { + it("Initial state on load with no existing location info", async () => { + let mobileLocationQuestions = { + addressQuestions: { + streetAddress: "", + apartmentNumberOrBusinessName: "", + city: "", + state: "", + zipCode: "", + }, + isVehicleProtected: null, + }; + + // Arrange + const wrapper = shallowMount(mobileLocationModalQuestions, { + mixins: [mockMixin], + props: { + modelValue: mobileLocationQuestions, + }, + attachTo: document.body, + }); + + // Assert + //expect(wrapper.html()).toEqual(expect.stringContaining(mockLinkCmsContent["BodyText"])); + }); +}); diff --git a/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.spec.js b/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.spec.js index c1e246707..72d299198 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.spec.js +++ b/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.spec.js @@ -11,20 +11,20 @@ const mockMixin = { if (cmsFieldName === "Answers") { return [ { - "AnswerImageUrl": "", - "Name": "YesAnswer", - "SubText": "", - "SubWidgetName": "", - "Text": "Yes" + AnswerImageUrl: "", + Name: "YesAnswer", + SubText: "", + SubWidgetName: "", + Text: "Yes", }, { - "AnswerImageUrl": "", - "Name": "NoAnswer", - "SubText": "", - "SubWidgetName": "", - "Text": "No" - } - ] + AnswerImageUrl: "", + Name: "NoAnswer", + SubText: "", + SubWidgetName: "", + Text: "No", + }, + ]; } return "QuestionText"; }), @@ -48,13 +48,12 @@ describe("service-zip-question.vue", () => { // Assert expect(modelValueAnswer).toEqual(answer); - }); it("Should emit to set value", async () => { // Arrange const yesAnswer = "YesAnswer"; - const noAnswer = "NoAnswer" + const noAnswer = "NoAnswer"; const wrapper = shallowMount(vehicleProtectedQuestion, { mixins: [mockMixin], props: {