From 03181bc5ab927dbad50e07af33d3b533e33c099a Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 6 Jul 2023 13:47:04 -0400 Subject: [PATCH] Add getter to inform cms content --- src/store/index.js | 3 +++ src/store/store.spec.js | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/store/index.js b/src/store/index.js index 035c4bcc0..3c0ea1e39 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -523,6 +523,9 @@ export const getters = { ); return !!nonWindshieldItems?.length; }, + isMobileAppointment: (state) => { + return state.order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE; + }, lineItems: (state) => state.order.lineItems, pageData: (state) => (page) => { return state.applicationUser.pageData[page]; diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 1ea0125b0..4a6788433 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -4,6 +4,7 @@ import { storeMutations } from "@/constants/store-mutations"; import { storeActions } from "@/constants/store-actions"; import { experimentTriggers } from "@/constants/experiments"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; +import { AppointmentTypeStrings } from "@/constants/schedule-constants"; // Mock global method globalMethods.callHttpClient = jest.fn(); @@ -2869,6 +2870,45 @@ describe("Getters", () => { expect(getters.payment(storeState).insuranceCoverage.isVerified).toEqual(true); }); + describe("isMobileAppointment", () => { + it("Should return true for mobile appointments", () => { + // Arrange + const storeState = state; + + // Act + mutations.updateServiceLocation(storeState, { + appointmentType: AppointmentTypeStrings.MOBILE, + }); + + // Assert + expect(getters.isMobileAppointment(storeState)).toBe(true); + }); + + it("Should return false for non-mobile appointments", () => { + // Arrange + const storeState = state; + + // Act + mutations.updateServiceLocation(storeState, { + appointmentType: AppointmentTypeStrings.IN_SHOP, + }); + + // Assert + expect(getters.isMobileAppointment(storeState)).toBe(false); + }); + + it("Should return false for null appointments", () => { + // Arrange + const storeState = state; + + // Act + mutations.updateServiceLocation(storeState, { appointmentType: null }); + + // Assert + expect(getters.isMobileAppointment(storeState)).toBe(false); + }); + }); + describe("experimentOrder", () => { test("glassToReplace, glassParts, and otherParts are null > return correct experimentOrder values", () => { // Arrange