Completed unit tests
This commit is contained in:
parent
6c8438beac
commit
40bc9b9a75
3 changed files with 89 additions and 5 deletions
|
|
@ -323,6 +323,30 @@ describe("service-location.vue", () => {
|
||||||
expect(wrapper.vm.mobileLocationQuestions).toStrictEqual(newMobileLocationQuestions);
|
expect(wrapper.vm.mobileLocationQuestions).toStrictEqual(newMobileLocationQuestions);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("resets appointment type selection when service zip code is updated by service zip modal", () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
||||||
|
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
|
const newServiceZipCodeQuestion = {
|
||||||
|
zipCode: "61606",
|
||||||
|
state: "IL",
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapper.vm.selectedAppointmentType = "Inshop";
|
||||||
|
|
||||||
|
const serviceZipCodeComponent = wrapper.findComponent({
|
||||||
|
ref: "serviceZipCodeQuestion",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.selectedAppointmentType).toStrictEqual(null);
|
||||||
|
});
|
||||||
|
|
||||||
test("displays military zip message when zip is updated", () => {
|
test("displays military zip message when zip is updated", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
@ -437,6 +461,61 @@ describe("service-location.vue", () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo);
|
expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("resets appointment type selection when service zip code is updated by mobile location modal when Mobile is not selected", () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
||||||
|
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
|
const newServiceZipCodeQuestion = {
|
||||||
|
zipCode: "61606",
|
||||||
|
state: "IL",
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapper.vm.selectedAppointmentType = "Dropoff";
|
||||||
|
|
||||||
|
const serviceZipCodeComponent = wrapper.findComponent({
|
||||||
|
ref: "serviceZipCodeQuestion",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.selectedAppointmentType).toStrictEqual(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("does not reset appointment type selection when service zip code is updated by mobile location modal when Mobile is selected", () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
const appointmentTypeMobile = "Mobile";
|
||||||
|
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
||||||
|
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
|
const mobileLocationQuestions = {
|
||||||
|
addressQuestions: {
|
||||||
|
streetAddress: "555 Some Street",
|
||||||
|
apartmentNumberOrBusinessName: "",
|
||||||
|
city: "Westerville",
|
||||||
|
state: "OH",
|
||||||
|
zipCode: "43081",
|
||||||
|
},
|
||||||
|
isVehicleProtected: "YesAnswer",
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapper.vm.selectedAppointmentType = "Mobile";
|
||||||
|
|
||||||
|
const mobileLocationComponent = wrapper.findComponent({
|
||||||
|
ref: "mobileLocationModalQuestions",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
mobileLocationComponent.vm.$emit("update:modelValue", mobileLocationQuestions);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.selectedAppointmentType).toStrictEqual(appointmentTypeMobile);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("serviceability logic", () => {
|
describe("serviceability logic", () => {
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,7 @@ export default {
|
||||||
set: function (newValue) {
|
set: function (newValue) {
|
||||||
if (newValue.zipCode !== this.zipCode) {
|
if (newValue.zipCode !== this.zipCode) {
|
||||||
this.resetMobileLocation();
|
this.resetMobileLocation();
|
||||||
|
this.selectedAppointmentType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state = newValue.state;
|
this.state = newValue.state;
|
||||||
|
|
@ -198,11 +199,12 @@ export default {
|
||||||
this.isVehicleProtected = newValue.isVehicleProtected;
|
this.isVehicleProtected = newValue.isVehicleProtected;
|
||||||
|
|
||||||
this.mobileLocationValidationField = "isValid";
|
this.mobileLocationValidationField = "isValid";
|
||||||
|
|
||||||
|
if ((newValue.zipCode !== this.zipCode) && !this.selectedAppointmentType == "Mobile") {
|
||||||
|
this.selectedAppointmentType = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
displayMilitaryZipAlert() {
|
|
||||||
return this.zipContainsMilitaryBase && this.isServiceableMobile;
|
|
||||||
},
|
|
||||||
isServiceableMobile() {
|
isServiceableMobile() {
|
||||||
if (this.isRecalibrationServiceableMobile !== null) {
|
if (this.isRecalibrationServiceableMobile !== null) {
|
||||||
return this.isGlassServiceableMobile && this.isRecalibrationServiceableMobile;
|
return this.isGlassServiceableMobile && this.isRecalibrationServiceableMobile;
|
||||||
|
|
@ -217,6 +219,9 @@ export default {
|
||||||
return this.isGlassServiceableInshop;
|
return this.isGlassServiceableInshop;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
displayMilitaryZipAlert() {
|
||||||
|
return this.zipContainsMilitaryBase && this.isServiceableMobile;
|
||||||
|
},
|
||||||
displayServiceableMobileOnly() {
|
displayServiceableMobileOnly() {
|
||||||
return this.isServiceableMobile && !this.isServiceableInshop;
|
return this.isServiceableMobile && !this.isServiceableInshop;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -931,10 +931,10 @@ export const actions = {
|
||||||
return globalMethods.callMockHttpClient({
|
return globalMethods.callMockHttpClient({
|
||||||
method: endpoints.GetServiceabilityDetails.method,
|
method: endpoints.GetServiceabilityDetails.method,
|
||||||
//TODO: Remove Mocky Endpoints
|
//TODO: Remove Mocky Endpoints
|
||||||
endpoint: "https://run.mocky.io/v3/59e1a644-cf16-4f08-8069-1ab2a1e38f79", // NoShopsAvailable
|
//endpoint: "https://run.mocky.io/v3/59e1a644-cf16-4f08-8069-1ab2a1e38f79", // NoShopsAvailable
|
||||||
//endpoint: "https://run.mocky.io/v3/4fe1fb89-dd56-4e4a-9af2-96bd1ab77847", // ForcedInshop
|
//endpoint: "https://run.mocky.io/v3/4fe1fb89-dd56-4e4a-9af2-96bd1ab77847", // ForcedInshop
|
||||||
//endpoint: "https://run.mocky.io/v3/e2eaa097-6ea5-4906-af53-901edaa94939", // ForcedMobile
|
//endpoint: "https://run.mocky.io/v3/e2eaa097-6ea5-4906-af53-901edaa94939", // ForcedMobile
|
||||||
//endpoint: "https://run.mocky.io/v3/1811a1fe-12a7-48f3-939e-d10a9b77dd25", // All Options
|
endpoint: "https://run.mocky.io/v3/1811a1fe-12a7-48f3-939e-d10a9b77dd25", // All Options
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Restore this when CSR-1104 is 100% complete
|
// TODO: Restore this when CSR-1104 is 100% complete
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue