From fcfd46d40fce1c18bd0795a98cc517af4191f561 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 5 Oct 2023 11:22:10 -0400 Subject: [PATCH 1/3] add a couple missing getters --- src/store/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 1e8e95de..91ba5f56 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -11,7 +11,7 @@ import applicationConfig from '@/constants/application-config'; import issPageValues from '@/router/router-constants/issPage-values'; import damageLocationsSelected from '@/constants/damage-locations-selected'; import coverageStatuses from '@/constants/coverage-statuses'; -import { PREMIUM_FEE_PART_TYPE } from '@/constants/schedule-constants'; +import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from '@/constants/schedule-constants'; import getDateDifferenceInDays from '@/helpers/date-helper'; const storeId = 'main'; @@ -192,6 +192,8 @@ export const useMainStore = defineStore({ payment: (state) => state.order.payment, policy: (state) => state.order.policy, hasAnyNonWindshieldGlassParts: (state) => !state.order.policy.isDamageGlassOnly, + isMobileAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE, + isDropOffAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.DROP_OFF, isClaimRegistrationRequired: (state) => state.issConfig.isClaimRegistrationRequired, eventBusItem: (state) => (eventCategory, eventSubCategory) => { const matchedEvent = state.applicationUser.eventBus.find(({ category, subCategory }) => category === eventCategory && subCategory === eventSubCategory); From 19bc2e7d2d02bc4946893325764d3c02c8e748f9 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 5 Oct 2023 11:31:18 -0400 Subject: [PATCH 2/3] tests for isMobileAppointment --- src/store/store.spec.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/store/store.spec.js b/src/store/store.spec.js index bd8a5f2a..f736806b 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -4,6 +4,7 @@ import globalMethods from '@/global-methods.js'; import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js'; import coverageStatuses from '@/constants/coverage-statuses.js'; import { endpoints } from '@/constants/endpoints'; +import { AppointmentTypeStrings } from '@/constants/schedule-constants'; describe('Store', () => { let store; @@ -994,7 +995,7 @@ describe('Store', () => { describe('updatePolicyITACFlag method', () => { it('updatePolicyITACFlag updates policy.isITAC flag in store', () => { - // Assert + // Arrange const moqIsITAC = getRandomBoolean(); // Act @@ -1004,4 +1005,40 @@ describe('Store', () => { expect(store.order.policy.isITAC).toEqual(moqIsITAC); }); }); + + describe('isMobileAppointment', () => { + it('Should return true for mobile appointments', () => { + // Arrange + + // Act + store.updateServiceLocation({ + appointmentType: AppointmentTypeStrings.MOBILE + }); + + // Assert + expect(store.isMobileAppointment).toBe(true); + }); + + it('Should return false for non-mobile appointments', () => { + // Arrange + + // Act + store.updateServiceLocation({ + appointmentType: AppointmentTypeStrings.IN_SHOP + }); + + // Assert + expect(store.isMobileAppointment).toBe(false); + }); + + it('Should return false for null appointments', () => { + // Arrange + + // Act + store.updateServiceLocation({ appointmentType: null }); + + // Assert + expect(store.isMobileAppointment).toBe(false); + }); + }); }); From 121cda7182682d0df1f7ee5846b371b1b35933bf Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 5 Oct 2023 11:42:05 -0400 Subject: [PATCH 3/3] Include Mobile_Insurance --- src/store/index.js | 3 ++- src/store/store.spec.js | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 91ba5f56..79a600e0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -192,7 +192,8 @@ export const useMainStore = defineStore({ payment: (state) => state.order.payment, policy: (state) => state.order.policy, hasAnyNonWindshieldGlassParts: (state) => !state.order.policy.isDamageGlassOnly, - isMobileAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE, + isMobileAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE + || state.order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_INSURANCE, isDropOffAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.DROP_OFF, isClaimRegistrationRequired: (state) => state.issConfig.isClaimRegistrationRequired, eventBusItem: (state) => (eventCategory, eventSubCategory) => { diff --git a/src/store/store.spec.js b/src/store/store.spec.js index f736806b..aea99622 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1019,6 +1019,18 @@ describe('Store', () => { expect(store.isMobileAppointment).toBe(true); }); + it('Should return true for mobile-insurance appointments', () => { + // Arrange + + // Act + store.updateServiceLocation({ + appointmentType: AppointmentTypeStrings.MOBILE_INSURANCE + }); + + // Assert + expect(store.isMobileAppointment).toBe(true); + }); + it('Should return false for non-mobile appointments', () => { // Arrange @@ -1041,4 +1053,40 @@ describe('Store', () => { expect(store.isMobileAppointment).toBe(false); }); }); + + describe('isDropoffAppointment', () => { + it('Should return true for drop-off appointments', () => { + // Arrange + + // Act + store.updateServiceLocation({ + appointmentType: AppointmentTypeStrings.DROP_OFF + }); + + // Assert + expect(store.isDropOffAppointment).toBe(true); + }); + + it('Should return false for non-drop-off appointments', () => { + // Arrange + + // Act + store.updateServiceLocation({ + appointmentType: AppointmentTypeStrings.MOBILE + }); + + // Assert + expect(store.isDropOffAppointment).toBe(false); + }); + + it('Should return false for null appointments', () => { + // Arrange + + // Act + store.updateServiceLocation({ appointmentType: null }); + + // Assert + expect(store.isDropOffAppointment).toBe(false); + }); + }); });