Fixing tests
This commit is contained in:
parent
21d811c815
commit
24103335ee
2 changed files with 4 additions and 82 deletions
|
|
@ -75,8 +75,6 @@ function getShallowMountedComponent(initialData = {}, methodToRun = () => {}) {
|
|||
}
|
||||
});
|
||||
|
||||
// mountOptions.global.mocks["$store"] = store;
|
||||
|
||||
mountOptions.global.stubs = {
|
||||
siteFooter: footerStub,
|
||||
loadingModal: loadingModalStub
|
||||
|
|
@ -337,81 +335,4 @@ describe('schedule-page.vue', () => {
|
|||
// Assert
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
||||
});
|
||||
test('for mobile appts, updateSupportingItems should call store action to save supporting items', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent();
|
||||
wrapper.vm.mainStore.order.serviceLocation.appointmentType = AppointmentTypeStrings.MOBILE;
|
||||
wrapper.vm.mobilePremiumAppointmentFee = 14.99;
|
||||
wrapper.vm.selectedTimeSlotInfo.isPremiumAppointment = true;
|
||||
wrapper.vm.mainStore.lineItems.supportingItems = [
|
||||
{
|
||||
partNumber: 'EARLY BIRD',
|
||||
description: null,
|
||||
partType: 'EARLY BIRD',
|
||||
laborAmount: 0,
|
||||
sellingPrice: 0,
|
||||
kitPrice: 0
|
||||
}
|
||||
];
|
||||
const store = useMainStore();
|
||||
|
||||
// Act
|
||||
await wrapper.vm.updateSupportingItems();
|
||||
|
||||
// Assert
|
||||
expect(store.saveSupportingItemsSuppressingStateResetting).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.vm.mainStore.lineItems.supportingItems)
|
||||
.toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
partType: 'EARLY BIRD'
|
||||
})
|
||||
]));
|
||||
});
|
||||
test(
|
||||
'for Inshop appts, updateSupportingItems should call store action to save supporting items WITHOUT the EARLY BIRD supporting item',
|
||||
async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent();
|
||||
wrapper.vm.mainStore.order.serviceLocation.appointmentType = AppointmentTypeStrings.IN_SHOP;
|
||||
wrapper.vm.mobilePremiumAppointmentFee = 14.99;
|
||||
wrapper.vm.selectedTimeSlotInfo.isPremiumAppointment = true;
|
||||
wrapper.vm.mainStore.lineItems.supportingItems = [
|
||||
{
|
||||
partNumber: 'EARLY BIRD',
|
||||
description: null,
|
||||
partType: 'EARLY BIRD',
|
||||
laborAmount: 0,
|
||||
sellingPrice: 0,
|
||||
kitPrice: 0
|
||||
}
|
||||
];
|
||||
const store = useMainStore();
|
||||
|
||||
// Act
|
||||
await wrapper.vm.updateSupportingItems();
|
||||
|
||||
// Assert
|
||||
expect(store.saveSupportingItemsSuppressingStateResetting).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.vm.mainStore.lineItems.supportingItems)
|
||||
.not.toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
partType: 'EARLY BIRD'
|
||||
})
|
||||
]));
|
||||
}
|
||||
);
|
||||
test('if no EARLY BIRD supporting item, then updateSupportingItems should NOT call store action', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent();
|
||||
wrapper.vm.mainStore.order.serviceLocation.appointmentType = AppointmentTypeStrings.MOBILE;
|
||||
wrapper.vm.mobilePremiumAppointmentFee = 14.99;
|
||||
wrapper.vm.selectedTimeSlotInfo.isPremiumAppointment = false;
|
||||
wrapper.vm.mainStore.lineItems.supportingItems = [];
|
||||
const store = useMainStore();
|
||||
// Act
|
||||
await wrapper.vm.updateSupportingItems();
|
||||
|
||||
// Assert
|
||||
expect(store.saveSupportingItemsSuppressingStateResetting).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -268,9 +268,7 @@ export default {
|
|||
return { mainStore };
|
||||
},
|
||||
data() {
|
||||
const { supportingItems } = useMainStore().lineItems;
|
||||
return {
|
||||
supportingItems,
|
||||
selectedDate: this.getSelectedDate(),
|
||||
selectedTimeSlotInfo: this.getSelectedTimeSlotInfo(),
|
||||
selectableDatesData: [],
|
||||
|
|
@ -293,6 +291,9 @@ export default {
|
|||
}
|
||||
|
||||
return this.selectableDatesData.days?.find((selectableDate) => selectableDate.date === this.selectedDate);
|
||||
},
|
||||
supportingItems() {
|
||||
return useMainStore().lineItems.supportingItems;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
|
@ -363,7 +364,7 @@ export default {
|
|||
},
|
||||
getSelectedTimeSlotInfo() {
|
||||
const isPremiumAppointment =
|
||||
!!this.supportingItems.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE)
|
||||
!!(this.supportingItems?.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE) ?? [])
|
||||
.length > 0;
|
||||
|
||||
const selectedTimeSlotInfo = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue