CSR-886: unit tests formatting updates

This commit is contained in:
Adam Caouette 2023-08-14 11:09:05 -04:00
parent a8154dc8c6
commit 80e7248bd9

View file

@ -89,7 +89,7 @@ beforeEach(() => {
date: "2019-01-01",
startTime: "09:00",
endTime: "10:00",
routeCode: "000"
routeCode: "000",
},
lineItems: {
glassParts: [
@ -135,7 +135,7 @@ describe("schedule.vue...", () => {
store.getters.order.serviceLocation.appointmentType = "Mobile";
store.getters.order.serviceLocation.provider = null;
//Act
//Act
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
//Assert
@ -265,45 +265,45 @@ describe("schedule.vue...", () => {
expect.objectContaining({
days: expect.any(Array),
estimatedServiceMinutesMaximum: expect.any(Number),
estimatedServiceMinutesMinimum: expect.any(Number)
estimatedServiceMinutesMinimum: expect.any(Number),
})
);
expect(wrapper.vm.mobilePremiumAppointmentFee).toStrictEqual(
expect.objectContaining({
partNumber: expect.any(String)
partNumber: expect.any(String),
})
);
expect(wrapper.vm.updateFooterButtonText).toHaveBeenCalled();
});
});
describe("computed properties...", () => {
test("timeSlotsForSelectedDate should return timeslots if selected date is available", () => {
//Arrange
const { wrapper } = setupMocks({});
wrapper.vm.selectableDatesData = {
days: [{
"date": "2022-11-11",
"timeSlots": [
{
"id": "1820I-01820-M-I*20425*AM",
"startTime": "08:00",
"endTime": "12:00",
"offerPremium": true
},
{
"id": "1820I-01820-M-I*20425*PM",
"startTime": "12:00",
"endTime": "17:00",
"offerPremium": false
}
]
}],
days: [
{
date: "2022-11-11",
timeSlots: [
{
id: "1820I-01820-M-I*20425*AM",
startTime: "08:00",
endTime: "12:00",
offerPremium: true,
},
{
id: "1820I-01820-M-I*20425*PM",
startTime: "12:00",
endTime: "17:00",
offerPremium: false,
},
],
},
],
};
wrapper.setData({
selectedDate: "2022-11-11"
selectedDate: "2022-11-11",
});
//Act
@ -312,46 +312,45 @@ describe("schedule.vue...", () => {
//Assert
expect(testValue).toStrictEqual(
expect.objectContaining({
"date": "2022-11-11"
date: "2022-11-11",
})
);
});
test("timeSlotsForSelectedDate should be null if no date has been selected", () => {
//Arrange
const { wrapper } = setupMocks({});
wrapper.vm.selectableDatesData = {
days: [{
"date": "2022-11-11",
"timeSlots": [
{
"id": "1820I-01820-M-I*20425*AM",
"startTime": "08:00",
"endTime": "12:00",
"offerPremium": true
},
{
"id": "1820I-01820-M-I*20425*PM",
"startTime": "12:00",
"endTime": "17:00",
"offerPremium": false
}
]
}],
days: [
{
date: "2022-11-11",
timeSlots: [
{
id: "1820I-01820-M-I*20425*AM",
startTime: "08:00",
endTime: "12:00",
offerPremium: true,
},
{
id: "1820I-01820-M-I*20425*PM",
startTime: "12:00",
endTime: "17:00",
offerPremium: false,
},
],
},
],
};
wrapper.setData({
selectedDate: undefined
selectedDate: undefined,
});
//Act
const testValue = wrapper.vm.timeSlotsForSelectedDate;
//Assert
expect(testValue).toBe(null)
expect(testValue).toBe(null);
});
});
});
@ -367,10 +366,7 @@ describe("schedule.vue...", () => {
const testValue = wrapper.vm.getServiceZipCtuCodeFromStore();
//Assert
expect(testValue).toStrictEqual(
"01234"
);
expect(testValue).toStrictEqual("01234");
});
test("openInshopTimeSlotsModal should trigger openModal method", () => {
@ -385,7 +381,6 @@ describe("schedule.vue...", () => {
//Assert
expect(wrapper.vm.$refs.timeSlotModalQuestion.openModal).toBeCalled();
});
test("getSelectedRouteCode should return schedule routeCode", () => {
@ -400,14 +395,9 @@ describe("schedule.vue...", () => {
const testValue = wrapper.vm.getSelectedRouteCode();
//Assert
expect(testValue).toStrictEqual(
"000"
);
expect(testValue).toStrictEqual("000");
});
test("timeSlotModalClosed should null any selected date when there's no route code", () => {
//Arrange
const { wrapper } = setupMocks({});
@ -415,15 +405,15 @@ describe("schedule.vue...", () => {
days: [],
};
wrapper.setData({
selectedDate: "1980-05-05"
selectedDate: "1980-05-05",
});
wrapper.setData({
selectedTimeSlot: {
date: "2019-01-01",
startTime: "09:00",
endTime: "10:00",
routeCode: null
}
routeCode: null,
},
});
//Act
@ -431,10 +421,8 @@ describe("schedule.vue...", () => {
//Assert
expect(wrapper.vm.selectedDate).toBe(null);
});
test("getDisplayTextForMilitaryTime should return the correctly formatted string", () => {
//Arrange
const { wrapper } = setupMocks({});
@ -455,7 +443,6 @@ describe("schedule.vue...", () => {
expect(testOutput2).toBe("3:30 PM");
expect(testOutput3).toBe("3 PM");
expect(testOutput4).toBe("3:30 PM");
});
test("getDisplayTextForMilitaryTime should return the correctly formatted string", () => {
@ -471,11 +458,11 @@ describe("schedule.vue...", () => {
wrapper.vm.backButtonAction();
//Assert
expect(wrapper.vm.$router.navigateWithoutSaving).toBeCalledWith("CLICKED_BACK", "testRoute");
expect(wrapper.vm.$router.navigateWithoutSaving).toBeCalledWith(
"CLICKED_BACK",
"testRoute"
);
});
});
test("forwardButtonAction should call route method navigateWithoutSaving", async () => {
@ -497,18 +484,19 @@ describe("schedule.vue...", () => {
expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
});
test("for mobile appts, updateSupportingItems should call store action to save supporting items", async () => {
//Arrange
store.getters.order.serviceLocation.appointmentType = "Mobile";
store.getters.lineItems.supportingItems = [{
"partNumber": "EARLY BIRD",
"description": null,
"partType": "EARLY BIRD",
"laborAmount": 0,
"sellingPrice": 0,
"kitPrice": 0
}];
store.getters.lineItems.supportingItems = [
{
partNumber: "EARLY BIRD",
description: null,
partType: "EARLY BIRD",
laborAmount: 0,
sellingPrice: 0,
kitPrice: 0,
},
];
const { wrapper } = setupMocks({});
wrapper.vm.dispatchStoreAction = jest.fn(() => {
return {
@ -522,8 +510,8 @@ describe("schedule.vue...", () => {
startTime: "09:00",
endTime: "10:00",
routeCode: null,
isPremiumAppointment: true
}
isPremiumAppointment: true,
},
});
//Act
@ -534,25 +522,26 @@ describe("schedule.vue...", () => {
"saveSupportingItemsSuppressingStateResetting",
expect.arrayContaining([
expect.objectContaining({
partType: "EARLY BIRD"
})
partType: "EARLY BIRD",
}),
]),
expect.anything()
);
});
test("for Inshop appts, updateSupportingItems should call store action to save supporting items WITHOUT the EARLY BIRD supporting item", async () => {
//Arrange
store.getters.order.serviceLocation.appointmentType = "Inshop";
store.getters.lineItems.supportingItems = [{
"partNumber": "EARLY BIRD",
"description": null,
"partType": "EARLY BIRD",
"laborAmount": 0,
"sellingPrice": 0,
"kitPrice": 0
}];
store.getters.lineItems.supportingItems = [
{
partNumber: "EARLY BIRD",
description: null,
partType: "EARLY BIRD",
laborAmount: 0,
sellingPrice: 0,
kitPrice: 0,
},
];
const { wrapper } = setupMocks({});
wrapper.vm.dispatchStoreAction = jest.fn(() => {
return {
@ -566,8 +555,8 @@ describe("schedule.vue...", () => {
startTime: "09:00",
endTime: "10:00",
routeCode: null,
isPremiumAppointment: true
}
isPremiumAppointment: true,
},
});
//Act
@ -578,12 +567,11 @@ describe("schedule.vue...", () => {
"saveSupportingItemsSuppressingStateResetting",
expect.not.arrayContaining([
expect.objectContaining({
partType: "EARLY BIRD"
})
partType: "EARLY BIRD",
}),
]),
expect.anything()
);
});
test("if no EARLY BIRD supporting item, then updateSupportingItems should NOT call store action", async () => {
@ -603,8 +591,8 @@ describe("schedule.vue...", () => {
startTime: "09:00",
endTime: "10:00",
routeCode: null,
isPremiumAppointment: false
}
isPremiumAppointment: false,
},
});
//Act
@ -612,9 +600,7 @@ describe("schedule.vue...", () => {
//Assert
expect(wrapper.vm.dispatchStoreAction).not.toBeCalled();
});
});
const mockCmsContent = {};