CASH-816 fixed unit tests and removed stray comment in shopQuestionPopup
This commit is contained in:
Johnny shultz 2025-06-30 23:47:23 -04:00
parent 1b12017f63
commit 0036d4f9ca
2 changed files with 217 additions and 37 deletions

View file

@ -219,7 +219,13 @@ describe("service-location.vue", () => {
// Arrange
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
/* ******NOTE: if we ever want to revert back to the old way of service location using shopQuestion instead of shopQuestionPopup uncomment all 30 of the lines in this file that read - wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn(); - , and commment all of the blocks of code referencing shopQuestionPopup directly under them. Also remove reference to shopQuestionPopup in the setupMocks function*/
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({ ref: "shopQuestionPopup" });
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
const mobileFeePart = {
partNumber: "MOBILE FEE",
@ -387,7 +393,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -414,7 +426,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -441,7 +459,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -468,7 +492,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -495,7 +525,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -523,7 +559,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -551,7 +593,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -579,7 +627,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -607,7 +661,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -635,7 +695,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -663,7 +729,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -691,7 +763,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -719,7 +797,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -747,7 +831,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -775,7 +865,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -806,7 +902,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -833,7 +935,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -860,7 +968,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -888,7 +1002,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -916,7 +1036,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -944,7 +1070,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -974,7 +1106,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -1002,7 +1140,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -1030,7 +1174,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -1058,7 +1208,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -1086,7 +1242,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -1114,7 +1276,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -1142,7 +1310,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -1172,7 +1346,13 @@ describe("service-location.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
//wrapper.vm.$refs.shopQuestion.initializeComponent = jest.fn();
const shopQuestionPopupComponent = wrapper.findComponent({
ref: "shopQuestionPopup",
});
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
// Act
await serviceLocation.beforeRouteEnter.call(
@ -1199,5 +1379,12 @@ function setupMocks({ mountOptionsMockData = {} }) {
const mountOptions = getMountOptions(mountOptionsMockData);
const wrapper = shallowMount(serviceLocation, mountOptions);
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
if (!wrapper.vm.shopProviderData) {
wrapper.vm.shopProviderData = { shopProviders: [] };
}
const shopQuestionPopupComponent = wrapper.findComponent({ ref: "shopQuestionPopup" });
if (shopQuestionPopupComponent.exists()) {
shopQuestionPopupComponent.vm.initializeComponent = jest.fn();
}
return { wrapper, apiPromise };
}

View file

@ -296,13 +296,6 @@ export default {
const zipCode = shopProvider.address.zipCode;
const distanceInMiles = Math.round(shopProvider.distanceInMiles * 2) / 2;
// const startDate = new Date();
// const endDate = new Date();
// endDate.setDate(startDate.getDate() + 6);
// const formattedStartDate = startDate.toISOString().split("T")[0];
// const formattedEndDate = endDate.toISOString().split("T")[0];
return {
buttonLabel: city,
buttonLabelSubCopy: `${distanceInMiles} mi`,