Unit tests - first one completed

This commit is contained in:
Scott Kiener 2023-07-28 11:15:29 -04:00
parent 49347eb4be
commit 653918944e

View file

@ -87,13 +87,29 @@ afterEach(() => {
}); });
describe("time-slot-modal-list-button-question.vue", () => { describe("time-slot-modal-list-button-question.vue", () => {
test.only("IsInsurance false should navigateWithSaving", async () => { test.only("When selected time slot is changed, a correctly formatted selectedTimeSlot should be emitted", async () => {
//Arrange //Arrange
const date = "2023-07-01";
const timeSlotId = "testRouteCodeId";
const startTime = "8:00 AM";
const endTime = "8:30 AM";
const jobMaxMinutes = 100;
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
customMountOptions: { customMountOptions: {
router: { router: {
navigateWithSaving: jest.fn(), navigateWithSaving: jest.fn(),
}, },
propsData: {
estimatedServiceMinutesMaximum: jobMaxMinutes,
dateAndTimeSlotData: {
date: date,
timeSlots: [{
id: timeSlotId,
startTime: startTime,
endTime: endTime,
}]
}
}
}, },
}); });
@ -111,11 +127,8 @@ describe("time-slot-modal-list-button-question.vue", () => {
// openModal() { return null}, // openModal() { return null},
// closeModal() {return null}, // closeModal() {return null},
// }; // };
wrapper.vm.dateAndTimeSlotData.timeSlots = [{
}];
wrapper.vm.$refs.timeSlots.closeModal = jest.fn(); wrapper.vm.$refs.timeSlots.closeModal = jest.fn();
wrapper.vm.selectedTimeSlotId = "testRouteCodeId"; wrapper.vm.selectedTimeSlotId = timeSlotId;
//await nextTick(); //await nextTick();
@ -123,7 +136,13 @@ describe("time-slot-modal-list-button-question.vue", () => {
//Act //Act
//await wrapper.vm.forwardButtonAction(); //await wrapper.vm.forwardButtonAction();
const expectedEmit = const expectedEmit = [[{
date: date,
routeCode: timeSlotId,
startTime: startTime,
endTime: endTime,
jobMaxMinutes: jobMaxMinutes.toString(),
}]];
//Assert //Assert
expect(wrapper.emitted()["update:modelValue"]).toEqual(expectedEmit); expect(wrapper.emitted()["update:modelValue"]).toEqual(expectedEmit);
}); });
@ -470,6 +489,7 @@ function setupMocks({ customMountOptions }) {
const mountOptions = getMountOptions({ const mountOptions = getMountOptions({
...customMountOptions, ...customMountOptions,
}); });
console.log(mountOptions);
mountOptions.global.mocks["$store"] = store; mountOptions.global.mocks["$store"] = store;
mountOptions["attachTo"] = document.body; mountOptions["attachTo"] = document.body;
mountOptions.mixins = [{ mountOptions.mixins = [{
@ -479,8 +499,6 @@ function setupMocks({ customMountOptions }) {
}]; }];
const questionText = "Question Text";
const wrapper = shallowMount(timeSlotModalQuestion, mountOptions); const wrapper = shallowMount(timeSlotModalQuestion, mountOptions);
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();
return { wrapper }; return { wrapper };