fixed unit tests

This commit is contained in:
Leah Schumann 2023-03-06 10:10:58 -05:00
parent ebbc522c1c
commit acc8e791af
4 changed files with 58 additions and 33 deletions

View file

@ -332,8 +332,6 @@ describe("mobile-location-modal-questions.vue", () => {
expect(wrapper.vm.internalModel.addressQuestions.streetAddress).toEqual(""); expect(wrapper.vm.internalModel.addressQuestions.streetAddress).toEqual("");
expect(wrapper.vm.internalModel.addressQuestions.apartmentNumberOrBusinessName).toEqual(""); expect(wrapper.vm.internalModel.addressQuestions.apartmentNumberOrBusinessName).toEqual("");
expect(wrapper.vm.internalModel.addressQuestions.city).toEqual(""); expect(wrapper.vm.internalModel.addressQuestions.city).toEqual("");
expect(wrapper.vm.internalModel.addressQuestions.state).toEqual("");
expect(wrapper.vm.internalModel.addressQuestions.zipCode).toEqual("");
expect(wrapper.vm.internalModel.isVehicleProtected).toEqual(null); expect(wrapper.vm.internalModel.isVehicleProtected).toEqual(null);
}); });
}); });

View file

@ -63,7 +63,6 @@ export default {
return { return {
internalModel: deepClone(this.modelValue), internalModel: deepClone(this.modelValue),
displayInvalidZipAlert: false, displayInvalidZipAlert: false,
modalName: "MobileLocationModalWidget",
}; };
}, },
props: { props: {
@ -108,6 +107,9 @@ export default {
} }
return this.getCmsContent(this.linkWidgetName, "BodyText"); return this.getCmsContent(this.linkWidgetName, "BodyText");
}, },
modalName() {
return "MobileLocationModalWidget";
},
modalHeaderText() { modalHeaderText() {
return this.getCmsContent(this.modalWidgetName, "HeaderText"); return this.getCmsContent(this.modalWidgetName, "HeaderText");
}, },
@ -115,9 +117,6 @@ export default {
const cmsContentText = this.getCmsContent("MobileFeeDisclaimerWidget", "Text"); const cmsContentText = this.getCmsContent("MobileFeeDisclaimerWidget", "Text");
return cmsContentText.replaceAll("{custom:mobileFee}", this.mobileFee); return cmsContentText.replaceAll("{custom:mobileFee}", this.mobileFee);
}, },
modalFooterText() {
return this.getCmsContent(this.modalWidgetName, "FooterText");
},
mobileFee() { mobileFee() {
if (!this.modelValue.mobileFeePart) { if (!this.modelValue.mobileFeePart) {
return 0; return 0;
@ -127,7 +126,11 @@ export default {
this.modelValue.mobileFeePart.sellingPrice + this.modelValue.mobileFeePart.sellingPrice +
this.modelValue.mobileFeePart.kitPrice this.modelValue.mobileFeePart.kitPrice
); );
},
modalFooterText() {
return this.getCmsContent(this.modalWidgetName, "FooterText");
}, },
addressModel: { addressModel: {
get: function () { get: function () {
return this.modelValue.addressQuestions; return this.modelValue.addressQuestions;

View file

@ -177,6 +177,12 @@ describe("service-location.vue", () => {
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn(); wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn(); wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
const newServiceZipCodeQuestion = {
zipCode: "61606",
state: "IL",
isServiceable: true,
};
const mobileLocationQuestions = { const mobileLocationQuestions = {
addressQuestions: { addressQuestions: {
streetAddress: "5555 Sulgrave Dr", streetAddress: "5555 Sulgrave Dr",
@ -186,8 +192,7 @@ describe("service-location.vue", () => {
zipCode: "43054", zipCode: "43054",
}, },
isVehicleProtected: true, isVehicleProtected: true,
serviceZipCode: "43054", mobileFeePart: null,
mobileFee: 0,
}; };
wrapper.vm.mobileLocationQuestions = mobileLocationQuestions; wrapper.vm.mobileLocationQuestions = mobileLocationQuestions;
@ -196,11 +201,11 @@ describe("service-location.vue", () => {
streetAddress: "", streetAddress: "",
apartmentNumberOrBusinessName: "", apartmentNumberOrBusinessName: "",
city: "", city: "",
state: "", state: "IL",
zipCode: "", zipCode: "61606",
}, },
isVehicleProtected: null, isVehicleProtected: null,
serviceZipCode: "43081", mobileFeePart: null
}; };
const serviceZipCodeComponent = wrapper.findComponent({ const serviceZipCodeComponent = wrapper.findComponent({
@ -208,7 +213,7 @@ describe("service-location.vue", () => {
}); });
// Act // Act
serviceZipCodeComponent.vm.$emit("updated-service-zip-code", "43081"); serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
// Assert // Assert
expect(wrapper.vm.mobileLocationQuestions).toStrictEqual(newMobileLocationQuestions); expect(wrapper.vm.mobileLocationQuestions).toStrictEqual(newMobileLocationQuestions);
@ -230,7 +235,7 @@ describe("service-location.vue", () => {
zipCode: "", zipCode: "",
}, },
isVehicleProtected: null, isVehicleProtected: null,
serviceZipCode: "43081", mobileFeePart: null,
}; };
wrapper.vm.mobileLocationQuestions = mobileLocationQuestions; wrapper.vm.mobileLocationQuestions = mobileLocationQuestions;
@ -243,8 +248,7 @@ describe("service-location.vue", () => {
zipCode: "43054", zipCode: "43054",
}, },
isVehicleProtected: true, isVehicleProtected: true,
serviceZipCode: "43054", mobileFeePart: null,
mobileFee: 0,
}; };
const mobileLocationComponent = wrapper.findComponent({ const mobileLocationComponent = wrapper.findComponent({
@ -264,29 +268,50 @@ describe("service-location.vue", () => {
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn(); wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn(); wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
const serviceZipCodeInfo = { const mobileLocationQuestions = {
state: "OH", addressQuestions: {
zipCode: "43054", streetAddress: "",
isServiceable: true, apartmentNumberOrBusinessName: "",
city: "",
state: "",
zipCode: "",
},
isVehicleProtected: null,
mobileFeePart: null,
}; };
wrapper.vm.mobileLocationQuestions = mobileLocationQuestions;
const newServiceZipCodeInfo = { const newMobileLocationQuestions = {
state: "OH", addressQuestions: {
zipCode: "43081", streetAddress: "5555 Rustic Dr",
isServiceable: true, apartmentNumberOrBusinessName: "Apt 1",
city: "Westerville",
state: "OH",
zipCode: "43081",
},
isVehicleProtected: true,
mobileFeePart: null,
}; };
wrapper.vm.serviceZipCodeQuestion = serviceZipCodeInfo;
const mobileLocationComponent = wrapper.findComponent({ const mobileLocationComponent = wrapper.findComponent({
ref: "mobileLocationModalQuestions", ref: "mobileLocationModalQuestions",
}); });
// Act wrapper.vm.serviceZipCodeQuestion = {
mobileLocationComponent.vm.$emit("updated-zip-code", { zipCode: "61606",
state: "IL",
isServiceable: true,
};
const newServiceZipCodeInfo = {
state: "OH", state: "OH",
zipCode: "43081", zipCode: "43081",
isServiceable: true, isServiceable: true,
}); };
// Act
mobileLocationComponent.vm.$emit("update:modelValue", newMobileLocationQuestions);
// Assert // Assert
expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo); expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo);

View file

@ -128,12 +128,11 @@ export default {
}, },
methods: { methods: {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return true; return (
// return ( store.getters.lineItems.supportingItems !== null &&
// store.getters.lineItems.supportingItems !== null && store.getters.order.serviceLocation.zipCode !== null &&
// store.getters.order.serviceLocation.zipCode !== null && store.getters.payment.isInsurance !== null
// store.getters.payment.isInsurance !== null );
// );
}, },
setData(mobileFeePart) { setData(mobileFeePart) {
if (mobileFeePart) { if (mobileFeePart) {