Merge pull request #468 from Safelite/feature/richardson/SSR-673.3

add a couple missing getters
This commit is contained in:
brich1212safe 2023-10-05 13:01:14 -04:00 committed by GitHub
commit f7c46b96c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 90 additions and 2 deletions

View file

@ -11,7 +11,7 @@ import applicationConfig from '@/constants/application-config';
import issPageValues from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import damageLocationsSelected from '@/constants/damage-locations-selected'; import damageLocationsSelected from '@/constants/damage-locations-selected';
import coverageStatuses from '@/constants/coverage-statuses'; 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'; import getDateDifferenceInDays from '@/helpers/date-helper';
const storeId = 'main'; const storeId = 'main';
@ -192,6 +192,9 @@ export const useMainStore = defineStore({
payment: (state) => state.order.payment, payment: (state) => state.order.payment,
policy: (state) => state.order.policy, policy: (state) => state.order.policy,
hasAnyNonWindshieldGlassParts: (state) => !state.order.policy.isDamageGlassOnly, 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, isClaimRegistrationRequired: (state) => state.issConfig.isClaimRegistrationRequired,
eventBusItem: (state) => (eventCategory, eventSubCategory) => { eventBusItem: (state) => (eventCategory, eventSubCategory) => {
const matchedEvent = state.applicationUser.eventBus.find(({ category, subCategory }) => category === eventCategory && subCategory === eventSubCategory); const matchedEvent = state.applicationUser.eventBus.find(({ category, subCategory }) => category === eventCategory && subCategory === eventSubCategory);

View file

@ -4,6 +4,7 @@ import globalMethods from '@/global-methods.js';
import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js'; import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js';
import coverageStatuses from '@/constants/coverage-statuses.js'; import coverageStatuses from '@/constants/coverage-statuses.js';
import { endpoints } from '@/constants/endpoints'; import { endpoints } from '@/constants/endpoints';
import { AppointmentTypeStrings } from '@/constants/schedule-constants';
describe('Store', () => { describe('Store', () => {
let store; let store;
@ -994,7 +995,7 @@ describe('Store', () => {
describe('updatePolicyITACFlag method', () => { describe('updatePolicyITACFlag method', () => {
it('updatePolicyITACFlag updates policy.isITAC flag in store', () => { it('updatePolicyITACFlag updates policy.isITAC flag in store', () => {
// Assert // Arrange
const moqIsITAC = getRandomBoolean(); const moqIsITAC = getRandomBoolean();
// Act // Act
@ -1004,4 +1005,88 @@ describe('Store', () => {
expect(store.order.policy.isITAC).toEqual(moqIsITAC); 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);
});
});
}); });