Prettified and fixed unit tests

This commit is contained in:
Leah Schumann 2023-05-18 07:53:28 -04:00
parent 72315f779e
commit 27d44aae7a
2 changed files with 11 additions and 18 deletions

View file

@ -434,7 +434,7 @@ describe("shop-question.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mixins: [mockMixin], mixins: [mockMixin],
props: { props: {
modelValue: selectedProvider.providerNumber, modelValue: selectedProvider,
serviceZipCode: "43081", serviceZipCode: "43081",
selectedAppointmentType: "Dropoff", selectedAppointmentType: "Dropoff",
cmsWidgetName: cmsWidgetName, cmsWidgetName: cmsWidgetName,
@ -460,18 +460,7 @@ describe("shop-question.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mixins: [mockMixin], mixins: [mockMixin],
props: { props: {
modelValue: { modelValue: null,
address: {
city: "POWELL",
country: "US",
state: "OH",
streetAddress: "3938 POWELL RD",
zipCode: "43065",
},
distanceInMiles: 16.2690495685233,
providerNumber: "003341",
},
serviceZipCode: "43081",
selectedAppointmentType: "Dropoff", selectedAppointmentType: "Dropoff",
cmsWidgetName: cmsWidgetName, cmsWidgetName: cmsWidgetName,
}, },
@ -481,21 +470,24 @@ describe("shop-question.vue", () => {
}); });
// Act // Act
wrapper.vm.initializeComponent(shopQuestionInitialData); await wrapper.vm.initializeComponent(shopQuestionInitialData);
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(wrapper.vm.answers.length).toEqual(3);
await wrapper.setProps({ await wrapper.setProps({
selectedAppointmentType: "Inshop", selectedAppointmentType: "Inshop",
}); });
await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
// Assert // Assert
expect(wrapper.vm.answers.length).toEqual(3); expect(wrapper.vm.answers.length).toEqual(3);
}); });
// it("Should reload the shops when the service zip code changes", async () => { // it.only("Should reload the shops when the service zip code changes", async () => {
// // Arrange // // Arrange
// const { wrapper } = setupMocks({ // const { wrapper } = setupMocks({
// mixins: [mockMixin], // mixins: [mockMixin],
@ -514,7 +506,7 @@ describe("shop-question.vue", () => {
// serviceZipCode: "43081", // serviceZipCode: "43081",
// selectedAppointmentType: "Dropoff", // selectedAppointmentType: "Dropoff",
// cmsWidgetName: cmsWidgetName, // cmsWidgetName: cmsWidgetName,
// isDisplayed: true // isDisplayed: true,
// }, // },
// mountOptions: { // mountOptions: {
// attachTo: document.body, // attachTo: document.body,
@ -530,7 +522,7 @@ describe("shop-question.vue", () => {
// // Act // // Act
// wrapper.vm.initializeComponent(shopQuestionInitialData); // wrapper.vm.initializeComponent(shopQuestionInitialData);
// await wrapper.vm.$options.watch.serviceZipCode.handler.call(wrapper.vm, "43054"); // //await wrapper.vm.$options.watch.serviceZipCode.handler.call(wrapper.vm, "43054");
// // Assert // // Assert
// expect(wrapper.vm.shopProviders.length).toEqual(3); // expect(wrapper.vm.shopProviders.length).toEqual(3);

View file

@ -216,13 +216,14 @@ export default {
if (this.selectedAppointmentType) { if (this.selectedAppointmentType) {
const selectedShopIndex = this.getSelectedProviderIndex( const selectedShopIndex = this.getSelectedProviderIndex(
newValue, newValue,
this.modelValue.providerNumber this.modelValue?.providerNumber
); );
if (selectedShopIndex >= 3) { if (selectedShopIndex >= 3) {
await this.getNextShopsFromList(selectedShopIndex + 1); await this.getNextShopsFromList(selectedShopIndex + 1);
} else { } else {
await this.getNextShopsFromList(); await this.getNextShopsFromList();
await this.$nextTick();
} }
} }
}, },