diff --git a/src/store/index.js b/src/store/index.js index 1e8e95de..79a600e0 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,9 @@ 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 + || 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) => { const matchedEvent = state.applicationUser.eventBus.find(({ category, subCategory }) => category === eventCategory && subCategory === eventSubCategory); diff --git a/src/store/store.spec.js b/src/store/store.spec.js index bd8a5f2a..aea99622 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,88 @@ 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 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 + + // 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); + }); + }); + + 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); + }); + }); });