update unit tests based on changes

This commit is contained in:
Kroell 2023-04-21 13:48:11 -04:00
parent 2a73020aad
commit 351a08e8eb
2 changed files with 59 additions and 28 deletions

View file

@ -27,12 +27,42 @@ const mockGetServiceabilityDetails = (mockServiceZipCode) => {
return Promise.resolve(serviceabilityDetails); return Promise.resolve(serviceabilityDetails);
}; };
const mockGetZipCodeData = (mockServiceZipCode) => {
if (mockServiceZipCode === "43235") {
return {
containsMilitaryBase: false,
isValid: true,
state: "OH",
zipCodeCtu: "01820",
};
}
if (mockServiceZipCode === "61606") {
return {
containsMilitaryBase: false,
isValid: true,
state: "IL",
zipCodeCtu: "01526",
};
}
return {
containsMilitaryBase: false,
isValid: false,
state: null,
zipCodeCtu: null,
};
}
jest.mock( jest.mock(
"@/helpers/service-location-helper", "@/helpers/service-location-helper",
() => ({ () => ({
getServiceabilityDetails: jest.fn((mockServiceZipCode) => { getServiceabilityDetails: jest.fn((mockServiceZipCode) => {
return mockGetServiceabilityDetails(mockServiceZipCode); return mockGetServiceabilityDetails(mockServiceZipCode);
}), }),
getZipCodeData: jest.fn((mockServiceZipCode) => {
return mockGetZipCodeData(mockServiceZipCode);
}),
}) })
); );
@ -59,35 +89,36 @@ const mockMixin = {
} }
return null; return null;
}), }),
}
}
// getZipCodeData: jest.fn((zip) => {
// if (zip === "43235") {
// return {
// containsMilitaryBase: false,
// isValid: true,
// state: "OH",
// zipCodeCtu: "01820",
// };
// }
getZipCodeData: jest.fn((zip) => { // if (zip === "61606") {
if (zip === "43235") { // return {
return { // containsMilitaryBase: false,
containsMilitaryBase: false, // isValid: true,
isValid: true, // state: "IL",
state: "OH", // zipCodeCtu: "01526",
zipCodeCtu: "01820", // };
}; // }
}
if (zip === "61606") { // return {
return { // containsMilitaryBase: false,
containsMilitaryBase: false, // isValid: false,
isValid: true, // state: null,
state: "IL", // zipCodeCtu: null,
zipCodeCtu: "01526", // };
}; // }),
} // },
// };
return {
containsMilitaryBase: false,
isValid: false,
state: null,
zipCodeCtu: null,
};
}),
},
};
describe("service-zip-modal-question.vue", () => { describe("service-zip-modal-question.vue", () => {
it("Initial state on load with existing location info", async () => { it("Initial state on load with existing location info", async () => {

View file

@ -125,7 +125,7 @@ export default {
if (this.internalModel.zipCode !== this.modelValue.zipCode) { if (this.internalModel.zipCode !== this.modelValue.zipCode) {
this.resetAlerts(); this.resetAlerts();
const zipCodeData = await this.getZipCodeData(this.internalModel.zipCode); const zipCodeData = await getZipCodeData(this.internalModel.zipCode);
if (!zipCodeData.isValid) { if (!zipCodeData.isValid) {
this.displayInvalidZipAlert = true; this.displayInvalidZipAlert = true;