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({
|
||||
isZipServiceable: false
|
||||
isZipValid: true,
|
||||
isZipServiceable: false,
|
||||
vinVehicles: [{
|
||||
vin: "TEST_VIN",
|
||||
vehicle: {
|
||||
carId: "C0000"
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||
|
|
@ -54,6 +61,7 @@ describe("address-lookup.vue", () => {
|
|||
|
||||
// Assert
|
||||
expect(wrapper.findComponent({ ref: "alertNonServiceableZip" }).isVisible()).toBe(true);
|
||||
|
||||
});
|
||||
|
||||
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({
|
||||
isZipServiceable: false
|
||||
isZipValid: true,
|
||||
isZipServiceable: false,
|
||||
vinVehicles: [{
|
||||
vin: "TEST_VIN",
|
||||
vehicle: {
|
||||
carId: "C0000"
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
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);
|
||||
const wrapper = shallowMount(addressLookup, getMountOptions({
|
||||
actionList: [
|
||||
{
|
||||
actionName: storeActions.VALIDATE_ZIP,
|
||||
data: {
|
||||
isValid: isZipValid,
|
||||
isServiceable: isZipServiceable
|
||||
}
|
||||
},
|
||||
|
|
@ -667,7 +683,8 @@ function setupMocks({ isZipServiceable = true, lookupVinbyAddressResponse, parts
|
|||
}));
|
||||
|
||||
const apiResponses = {
|
||||
serviceZipValidationResponse:{
|
||||
serviceZipValidationResponse: {
|
||||
isValid: isZipValid,
|
||||
isServiceable: isZipServiceable
|
||||
},
|
||||
vinLookupResponse: {
|
||||
|
|
|
|||
|
|
@ -207,7 +207,6 @@ export default {
|
|||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
// If VIN Lookup by address is forbidden by State Restrictions then show an alert
|
||||
if (!resultMap.vinLookupResponse.isStatePermissible) {
|
||||
// State Restrictions forbid lookup by address
|
||||
|
|
@ -231,7 +230,9 @@ export default {
|
|||
const carFound = carsFound[0].vehicle;
|
||||
|
||||
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) {
|
||||
// Display Alert
|
||||
this.previouslyEnteredCarId = carFound.carId;
|
||||
|
|
@ -260,6 +261,7 @@ export default {
|
|||
|
||||
} else {
|
||||
// No VINS found.
|
||||
console.log("no vins");
|
||||
this.displayVinNotFoundAlert = true;
|
||||
return this.$refs.funnelFooter.removeLoader();
|
||||
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ describe("license-plate-lookup.vue", () => {
|
|||
|
||||
//Act
|
||||
await wrapper.setData({
|
||||
registrationZip: "55555"
|
||||
registrationZipCode: "55555"
|
||||
})
|
||||
wrapper.vm.getCmsContent = jest.fn();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
|
@ -328,7 +328,7 @@ describe("license-plate-lookup.vue", () => {
|
|||
|
||||
//Act
|
||||
await wrapper.setData({
|
||||
serviceZip: "55555"
|
||||
serviceZipCode: "55555"
|
||||
})
|
||||
wrapper.vm.getCmsContent = jest.fn();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
|
@ -344,9 +344,17 @@ describe("license-plate-lookup.vue", () => {
|
|||
const { wrapper } = setupMocks({});
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
||||
|
||||
await wrapper.setData({ registrationZip: "00000" });
|
||||
await wrapper.setData({ registrationZipCode: "00000" });
|
||||
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||
|
||||
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
vehicle: {
|
||||
carId: "C00000"
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
|
|
@ -366,11 +374,19 @@ describe("license-plate-lookup.vue", () => {
|
|||
await wrapper.setData({ registrationZip: "00000" });
|
||||
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||
|
||||
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
vehicle: {
|
||||
carId: "C00000"
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
|
||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZipQuestionWidget']");
|
||||
expect(serviceZipField.exists()).toBe(true);
|
||||
expect(serviceZipField.isVisible()).toBe(true);
|
||||
})
|
||||
|
|
@ -382,8 +398,17 @@ describe("license-plate-lookup.vue", () => {
|
|||
return { data: { isServiceable: false, state: "XX" } };
|
||||
});
|
||||
|
||||
await wrapper.setData({ registrationZip: "00000" });
|
||||
await wrapper.setData({ registrationZipCode: "00000" });
|
||||
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||
|
||||
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
vehicle: {
|
||||
carId: "C00000"
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
wrapper.vm.$router.navigate = jest.fn();
|
||||
// At this point, serviceZip field is shown
|
||||
|
|
@ -393,7 +418,7 @@ describe("license-plate-lookup.vue", () => {
|
|||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
|
||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZipQuestionWidget']");
|
||||
expect(serviceZipField.exists()).toBe(true);
|
||||
expect(serviceZipField.isVisible()).toBe(true); 3
|
||||
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();
|
||||
|
||||
// At this point, serviceZip field is shown
|
||||
await wrapper.setData({ serviceZip: serviceZip });
|
||||
await wrapper.setData({ serviceZipCode: serviceZip });
|
||||
|
||||
// Act
|
||||
|
||||
|
|
@ -427,7 +452,7 @@ describe("license-plate-lookup.vue", () => {
|
|||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
|
||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZipQuestionWidget']");
|
||||
expect(serviceZipField.exists()).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();
|
||||
|
||||
// At this point, serviceZip field is shown
|
||||
|
|
@ -512,6 +537,7 @@ function setupMocks({
|
|||
},
|
||||
},
|
||||
serviceZipValidationResponse: {
|
||||
isValid: true,
|
||||
isServiceable: isServiceable
|
||||
},
|
||||
registrationZipValidationResponse: {
|
||||
|
|
|
|||
|
|
@ -224,7 +224,8 @@ function setupMocks({ customMountOptions }) {
|
|||
|
||||
function mockOutPromises(carId = 'C00000') {
|
||||
const apiResponses = {
|
||||
validateZipResponse: {
|
||||
serviceZipValidationResponse: {
|
||||
isValid: true,
|
||||
isServiceable: true
|
||||
},
|
||||
vehicleLookupResponse: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue