Updated unit tests
This commit is contained in:
parent
de3810d3dd
commit
2184480eb2
4 changed files with 63 additions and 17 deletions
|
|
@ -38,7 +38,14 @@ describe("address-lookup.vue", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: false
|
isZipValid: true,
|
||||||
|
isZipServiceable: false,
|
||||||
|
vinVehicles: [{
|
||||||
|
vin: "TEST_VIN",
|
||||||
|
vehicle: {
|
||||||
|
carId: "C0000"
|
||||||
|
}
|
||||||
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||||
|
|
@ -54,6 +61,7 @@ describe("address-lookup.vue", () => {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.findComponent({ ref: "alertNonServiceableZip" }).isVisible()).toBe(true);
|
expect(wrapper.findComponent({ ref: "alertNonServiceableZip" }).isVisible()).toBe(true);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("if the address matches a different vehicle display the Matched Different VehicleAlert", async () => {
|
test("if the address matches a different vehicle display the Matched Different VehicleAlert", async () => {
|
||||||
|
|
@ -462,7 +470,14 @@ describe("address-lookup.vue", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: false
|
isZipValid: true,
|
||||||
|
isZipServiceable: false,
|
||||||
|
vinVehicles: [{
|
||||||
|
vin: "TEST_VIN",
|
||||||
|
vehicle: {
|
||||||
|
carId: "C0000"
|
||||||
|
}
|
||||||
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||||
|
|
@ -612,13 +627,14 @@ describe("address-lookup.vue", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({ isZipServiceable = true, lookupVinbyAddressResponse, partsOrQuestions = [], isStatePermissible = true, vinVehicles =[], carId = 'C0000'}) {
|
function setupMocks({ isZipValid = true, isZipServiceable = true, lookupVinbyAddressResponse, partsOrQuestions = [], isStatePermissible = true, vinVehicles =[], carId = 'C0000' }) {
|
||||||
store.commit(storeMutations.RESET_STATE);
|
store.commit(storeMutations.RESET_STATE);
|
||||||
const wrapper = shallowMount(addressLookup, getMountOptions({
|
const wrapper = shallowMount(addressLookup, getMountOptions({
|
||||||
actionList: [
|
actionList: [
|
||||||
{
|
{
|
||||||
actionName: storeActions.VALIDATE_ZIP,
|
actionName: storeActions.VALIDATE_ZIP,
|
||||||
data: {
|
data: {
|
||||||
|
isValid: isZipValid,
|
||||||
isServiceable: isZipServiceable
|
isServiceable: isZipServiceable
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -667,7 +683,8 @@ function setupMocks({ isZipServiceable = true, lookupVinbyAddressResponse, parts
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const apiResponses = {
|
const apiResponses = {
|
||||||
serviceZipValidationResponse:{
|
serviceZipValidationResponse: {
|
||||||
|
isValid: isZipValid,
|
||||||
isServiceable: isZipServiceable
|
isServiceable: isZipServiceable
|
||||||
},
|
},
|
||||||
vinLookupResponse: {
|
vinLookupResponse: {
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,6 @@ export default {
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
||||||
// If VIN Lookup by address is forbidden by State Restrictions then show an alert
|
// If VIN Lookup by address is forbidden by State Restrictions then show an alert
|
||||||
if (!resultMap.vinLookupResponse.isStatePermissible) {
|
if (!resultMap.vinLookupResponse.isStatePermissible) {
|
||||||
// State Restrictions forbid lookup by address
|
// State Restrictions forbid lookup by address
|
||||||
|
|
@ -231,7 +230,9 @@ export default {
|
||||||
const carFound = carsFound[0].vehicle;
|
const carFound = carsFound[0].vehicle;
|
||||||
|
|
||||||
this.isCarIdDifferent = carFound.carId !== this.$store.getters.vehicle.carId;
|
this.isCarIdDifferent = carFound.carId !== this.$store.getters.vehicle.carId;
|
||||||
|
console.log(this.isCarIdDifferent);
|
||||||
|
console.log(carFound.carId);
|
||||||
|
console.log(this.$store.getters.vehicle.carId);
|
||||||
if (this.isCarIdDifferent && carFound.carId !== this.previouslyEnteredCarId) {
|
if (this.isCarIdDifferent && carFound.carId !== this.previouslyEnteredCarId) {
|
||||||
// Display Alert
|
// Display Alert
|
||||||
this.previouslyEnteredCarId = carFound.carId;
|
this.previouslyEnteredCarId = carFound.carId;
|
||||||
|
|
@ -260,6 +261,7 @@ export default {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// No VINS found.
|
// No VINS found.
|
||||||
|
console.log("no vins");
|
||||||
this.displayVinNotFoundAlert = true;
|
this.displayVinNotFoundAlert = true;
|
||||||
return this.$refs.funnelFooter.removeLoader();
|
return this.$refs.funnelFooter.removeLoader();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
registrationZip: "55555"
|
registrationZipCode: "55555"
|
||||||
})
|
})
|
||||||
wrapper.vm.getCmsContent = jest.fn();
|
wrapper.vm.getCmsContent = jest.fn();
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
@ -328,7 +328,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
serviceZip: "55555"
|
serviceZipCode: "55555"
|
||||||
})
|
})
|
||||||
wrapper.vm.getCmsContent = jest.fn();
|
wrapper.vm.getCmsContent = jest.fn();
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
@ -344,9 +344,17 @@ describe("license-plate-lookup.vue", () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
||||||
|
|
||||||
await wrapper.setData({ registrationZip: "00000" });
|
await wrapper.setData({ registrationZipCode: "00000" });
|
||||||
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||||
|
|
||||||
|
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
|
||||||
|
data: {
|
||||||
|
vehicle: {
|
||||||
|
carId: "C00000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
|
@ -366,11 +374,19 @@ describe("license-plate-lookup.vue", () => {
|
||||||
await wrapper.setData({ registrationZip: "00000" });
|
await wrapper.setData({ registrationZip: "00000" });
|
||||||
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||||
|
|
||||||
|
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
|
||||||
|
data: {
|
||||||
|
vehicle: {
|
||||||
|
carId: "C00000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
|
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZipQuestionWidget']");
|
||||||
expect(serviceZipField.exists()).toBe(true);
|
expect(serviceZipField.exists()).toBe(true);
|
||||||
expect(serviceZipField.isVisible()).toBe(true);
|
expect(serviceZipField.isVisible()).toBe(true);
|
||||||
})
|
})
|
||||||
|
|
@ -382,8 +398,17 @@ describe("license-plate-lookup.vue", () => {
|
||||||
return { data: { isServiceable: false, state: "XX" } };
|
return { data: { isServiceable: false, state: "XX" } };
|
||||||
});
|
});
|
||||||
|
|
||||||
await wrapper.setData({ registrationZip: "00000" });
|
await wrapper.setData({ registrationZipCode: "00000" });
|
||||||
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||||
|
|
||||||
|
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
|
||||||
|
data: {
|
||||||
|
vehicle: {
|
||||||
|
carId: "C00000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
wrapper.vm.$router.navigate = jest.fn();
|
wrapper.vm.$router.navigate = jest.fn();
|
||||||
// At this point, serviceZip field is shown
|
// At this point, serviceZip field is shown
|
||||||
|
|
@ -393,7 +418,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
|
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZipQuestionWidget']");
|
||||||
expect(serviceZipField.exists()).toBe(true);
|
expect(serviceZipField.exists()).toBe(true);
|
||||||
expect(serviceZipField.isVisible()).toBe(true); 3
|
expect(serviceZipField.isVisible()).toBe(true); 3
|
||||||
expect(navigateToHeritage.navigateToHeritageFunnel).not.toHaveBeenCalled();
|
expect(navigateToHeritage.navigateToHeritageFunnel).not.toHaveBeenCalled();
|
||||||
|
|
@ -415,11 +440,11 @@ describe("license-plate-lookup.vue", () => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await wrapper.setData({ registrationZip: registrationZip });
|
await wrapper.setData({ registrationZipCode: registrationZip });
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// At this point, serviceZip field is shown
|
// At this point, serviceZip field is shown
|
||||||
await wrapper.setData({ serviceZip: serviceZip });
|
await wrapper.setData({ serviceZipCode: serviceZip });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
||||||
|
|
@ -427,7 +452,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
|
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZipQuestionWidget']");
|
||||||
expect(serviceZipField.exists()).toBe(true);
|
expect(serviceZipField.exists()).toBe(true);
|
||||||
expect(serviceZipField.isVisible()).toBe(true);
|
expect(serviceZipField.isVisible()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
@ -447,7 +472,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await wrapper.setData({ registrationZip: registrationZip });
|
await wrapper.setData({ registrationZipCode: registrationZip });
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// At this point, serviceZip field is shown
|
// At this point, serviceZip field is shown
|
||||||
|
|
@ -512,6 +537,7 @@ function setupMocks({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
serviceZipValidationResponse: {
|
serviceZipValidationResponse: {
|
||||||
|
isValid: true,
|
||||||
isServiceable: isServiceable
|
isServiceable: isServiceable
|
||||||
},
|
},
|
||||||
registrationZipValidationResponse: {
|
registrationZipValidationResponse: {
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,8 @@ function setupMocks({ customMountOptions }) {
|
||||||
|
|
||||||
function mockOutPromises(carId = 'C00000') {
|
function mockOutPromises(carId = 'C00000') {
|
||||||
const apiResponses = {
|
const apiResponses = {
|
||||||
validateZipResponse: {
|
serviceZipValidationResponse: {
|
||||||
|
isValid: true,
|
||||||
isServiceable: true
|
isServiceable: true
|
||||||
},
|
},
|
||||||
vehicleLookupResponse: {
|
vehicleLookupResponse: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue