CSR-416 Restructure license-plate-lookup.spec.js
This commit is contained in:
parent
3acea7906a
commit
d4530b9091
1 changed files with 311 additions and 340 deletions
|
|
@ -30,8 +30,8 @@ jest.mock("@/store", () => ({
|
||||||
dispatch: jest.fn(),
|
dispatch: jest.fn(),
|
||||||
getters: {
|
getters: {
|
||||||
order: {
|
order: {
|
||||||
customer: { emailAddress: "test@test.com"},
|
customer: { emailAddress: "test@test.com" },
|
||||||
serviceLocation: {zip: "11111"},
|
serviceLocation: { zip: "11111" },
|
||||||
},
|
},
|
||||||
vehicle: {
|
vehicle: {
|
||||||
carId: "TESTID",
|
carId: "TESTID",
|
||||||
|
|
@ -48,382 +48,353 @@ jest.mock("@/store", () => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
describe("license-plate-lookup.vue", () => {
|
||||||
test("CarId set, arePagePrerequisitesValid should be true ", async () => {
|
describe("get values from store", () => {
|
||||||
//Arrange
|
test("getLicensePlateFromStore returns store license plate", async () => {
|
||||||
const { wrapper } = setupMocks({});
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Act
|
// ACT
|
||||||
licensePlateLookup.beforeRouteEnter.call(
|
const licensePlate = wrapper.vm.getLicensePlateFromStore();
|
||||||
wrapper.vm,
|
|
||||||
{ query: { fmgPage: "license-plate-lookup" } },
|
|
||||||
undefined,
|
|
||||||
(c) => c(wrapper.vm)
|
|
||||||
);
|
|
||||||
|
|
||||||
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
// Assert
|
||||||
await nextTick();
|
expect(licensePlate).toEqual("TESTPLATE");
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(arePagePrerequisitesValid).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("BackButtonAction triggers a router.navigate change", async () => {
|
|
||||||
|
|
||||||
//Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
//Act
|
|
||||||
licensePlateLookup.beforeRouteEnter.call(
|
|
||||||
wrapper.vm,
|
|
||||||
{ query: { fmgPage: "license-plate-lookup" } },
|
|
||||||
undefined,
|
|
||||||
(c) => c(wrapper.vm)
|
|
||||||
);
|
|
||||||
|
|
||||||
wrapper.vm.backButtonAction();
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("getLicensePlateFromStore returns store license plate", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
// ACT
|
|
||||||
const licensePlate = wrapper.vm.getLicensePlateFromStore();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(licensePlate).toEqual("TESTPLATE");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("getRegistrationZipFromStore returns store registration zip", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
// ACT
|
|
||||||
const registrationZip = wrapper.vm.getRegistrationZipFromStore();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(registrationZip).toEqual("12345");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("getEmailFromStore returns store customer email", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
// ACT
|
|
||||||
const customerEmail = wrapper.vm.getEmailFromStore();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(customerEmail).toEqual("test@test.com");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("getServiceZipFromStore returns store service zip", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
// ACT
|
|
||||||
const serviceZip = wrapper.vm.getServiceZipFromStore();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(serviceZip).toEqual("11111");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("Navigate forward should be called and isCarId should be set to false when data entered matches store data on forwardButtonAction click", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
|
||||||
return {data: {isServiceable: true}};
|
|
||||||
});
|
});
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
|
||||||
return '';
|
test("getRegistrationZipFromStore returns store registration zip", async () => {
|
||||||
});
|
// Arrange
|
||||||
const vinLookup = {data: {vehicle: {carId: "TESTID"}}}
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
|
|
||||||
return {catch: () => vinLookup};
|
// ACT
|
||||||
|
const registrationZip = wrapper.vm.getRegistrationZipFromStore();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(registrationZip).toEqual("12345");
|
||||||
});
|
});
|
||||||
wrapper.vm.navigateForward = jest.fn();
|
|
||||||
|
|
||||||
//Act
|
test("getEmailFromStore returns store customer email", async () => {
|
||||||
licensePlateLookup.beforeRouteEnter.call(
|
// Arrange
|
||||||
wrapper.vm,
|
const { wrapper } = setupMocks({});
|
||||||
{ query: { fmgPage: "license-plate-lookup" } },
|
|
||||||
undefined,
|
|
||||||
(c) => c(wrapper.vm)
|
|
||||||
);
|
|
||||||
|
|
||||||
await wrapper.vm.forwardButtonAction();
|
// ACT
|
||||||
|
const customerEmail = wrapper.vm.getEmailFromStore();
|
||||||
|
|
||||||
//Assert
|
// Assert
|
||||||
expect(wrapper.vm.navigateForward).toHaveBeenCalled();
|
expect(customerEmail).toEqual("test@test.com");
|
||||||
expect(wrapper.vm.isCarIdDifferent).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("Function should stop and datam isRegistrationZipServicable should be set to false when service zip entered returns false on forwardButtonAction click", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
|
||||||
return {data: {isServiceable: false}};
|
|
||||||
});
|
});
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
|
||||||
return '';
|
|
||||||
});
|
|
||||||
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
|
||||||
//Act
|
|
||||||
licensePlateLookup.beforeRouteEnter.call(
|
|
||||||
wrapper.vm,
|
|
||||||
{ query: { fmgPage: "license-plate-lookup" } },
|
|
||||||
undefined,
|
|
||||||
(c) => c(wrapper.vm)
|
|
||||||
);
|
|
||||||
|
|
||||||
await wrapper.vm.forwardButtonAction();
|
test("getServiceZipFromStore returns store service zip", async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Assert
|
// ACT
|
||||||
expect(wrapper.vm.isRegistrationZipServicable).toEqual(false);
|
const serviceZip = wrapper.vm.getServiceZipFromStore();
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
// Assert
|
||||||
test("Function should stop and datam isCarIdDifferent should be set to true when carId entered doesn't match store carId or previously entered carId on forwardButtonAction click", async () => {
|
expect(serviceZip).toEqual("11111");
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
|
||||||
return {data: {isServiceable: true}};
|
|
||||||
});
|
});
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
});
|
||||||
return '';
|
|
||||||
});
|
describe("navigation", () => {
|
||||||
const vinLookup = {data: {vehicle: {carId: "TESTID1"}}}
|
test("BackButtonAction triggers a router.navigate change", async () => {
|
||||||
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
|
|
||||||
return {catch: () => vinLookup};
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
licensePlateLookup.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { fmgPage: "license-plate-lookup" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
|
||||||
|
wrapper.vm.backButtonAction();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
|
||||||
|
|
||||||
//Act
|
describe("on forwardButtonAction click", () => {
|
||||||
licensePlateLookup.beforeRouteEnter.call(
|
test("Navigate forward should be called and isCarId should be set to false when data entered matches store data on forwardButtonAction click", async () => {
|
||||||
wrapper.vm,
|
|
||||||
{ query: { fmgPage: "license-plate-lookup" } },
|
|
||||||
undefined,
|
|
||||||
(c) => c(wrapper.vm)
|
|
||||||
);
|
|
||||||
|
|
||||||
await wrapper.vm.forwardButtonAction();
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Assert
|
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
||||||
expect(wrapper.vm.isCarIdDifferent).toEqual(true);
|
return { data: { isServiceable: true } };
|
||||||
});
|
});
|
||||||
});
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
const vinLookup = { data: { vehicle: { carId: "TESTID" } } }
|
||||||
|
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
|
||||||
|
return { catch: () => vinLookup };
|
||||||
|
});
|
||||||
|
wrapper.vm.navigateForward = jest.fn();
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
//Act
|
||||||
test("Navigate forward should be called and isCarId should be set to true when carId entered matches previously entered carId and rest of data entered matches store data on forwardButtonAction click", async () => {
|
licensePlateLookup.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { fmgPage: "license-plate-lookup" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
|
||||||
// Arrange
|
await wrapper.vm.forwardButtonAction();
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
//Assert
|
||||||
return {data: {isServiceable: true}};
|
expect(wrapper.vm.navigateForward).toHaveBeenCalled();
|
||||||
|
expect(wrapper.vm.isCarIdDifferent).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Function should stop and datam isRegistrationZipServicable should be set to false when service zip entered returns false on forwardButtonAction click", async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
||||||
|
return { data: { isServiceable: false } };
|
||||||
|
});
|
||||||
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
||||||
|
|
||||||
|
//Act
|
||||||
|
licensePlateLookup.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { fmgPage: "license-plate-lookup" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.isRegistrationZipServicable).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Function should stop and datam isCarIdDifferent should be set to true when carId entered doesn't match store carId or previously entered carId on forwardButtonAction click", async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
||||||
|
return { data: { isServiceable: true } };
|
||||||
|
});
|
||||||
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
const vinLookup = { data: { vehicle: { carId: "TESTID1" } } }
|
||||||
|
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
|
||||||
|
return { catch: () => vinLookup };
|
||||||
|
});
|
||||||
|
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
||||||
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
|
|
||||||
|
//Act
|
||||||
|
licensePlateLookup.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { fmgPage: "license-plate-lookup" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.isCarIdDifferent).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Navigate forward should be called and isCarId should be set to true when carId entered matches previously entered carId and rest of data entered matches store data on forwardButtonAction click", async () => {
|
||||||
|
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
||||||
|
return { data: { isServiceable: true } };
|
||||||
|
});
|
||||||
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
const vinLookup = { data: { vehicle: { carId: "TESTID1" } } }
|
||||||
|
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
|
||||||
|
return { catch: () => vinLookup };
|
||||||
|
});
|
||||||
|
wrapper.vm.previouslyEnteredCarId = "TESTID1";
|
||||||
|
wrapper.vm.navigateForward = jest.fn();
|
||||||
|
|
||||||
|
//Act
|
||||||
|
licensePlateLookup.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { fmgPage: "license-plate-lookup" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.navigateForward).toHaveBeenCalled();
|
||||||
|
expect(wrapper.vm.isCarIdDifferent).toEqual(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
|
||||||
return '';
|
describe("navigateForward", () => {
|
||||||
});
|
test("NavigateAfterSave should be called if isCarIdDifferent is true and isSelectedGlassAvailableForVehicle is false when navigateForward is called", async () => {
|
||||||
const vinLookup = {data: {vehicle: {carId: "TESTID1"}}}
|
|
||||||
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
|
// Arrange
|
||||||
return {catch: () => vinLookup};
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
wrapper.vm.isCarIdDifferent = true;
|
||||||
|
wrapper.vm.isSelectedGlassAvailableForVehicle = false;
|
||||||
|
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
||||||
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
store.dispatch = jest.fn();
|
||||||
|
|
||||||
|
await wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.$router.navigateAfterSave).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("navigateAfterSaveToHeritageFunnel should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => {
|
||||||
|
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
wrapper.vm.isCarIdDifferent = false;
|
||||||
|
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
||||||
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
||||||
|
await wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(navigateToHeritage.navigateAfterSaveToHeritageFunnel).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
wrapper.vm.previouslyEnteredCarId = "TESTID1";
|
|
||||||
wrapper.vm.navigateForward = jest.fn();
|
|
||||||
|
|
||||||
//Act
|
|
||||||
licensePlateLookup.beforeRouteEnter.call(
|
|
||||||
wrapper.vm,
|
|
||||||
{ query: { fmgPage: "license-plate-lookup" } },
|
|
||||||
undefined,
|
|
||||||
(c) => c(wrapper.vm)
|
|
||||||
);
|
|
||||||
|
|
||||||
await wrapper.vm.forwardButtonAction();
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(wrapper.vm.navigateForward).toHaveBeenCalled();
|
|
||||||
expect(wrapper.vm.isCarIdDifferent).toEqual(true);
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
describe("button text", () => {
|
||||||
test("Button Text should revert to initial value when licensePlate textfield has new text", async () => {
|
test("Button Text should revert to initial value when licensePlate textfield has new text", async () => {
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
wrapper.vm.licensePlate = "NEWPLATE";
|
wrapper.vm.licensePlate = "NEWPLATE";
|
||||||
wrapper.vm.getCmsContent = jest.fn();
|
wrapper.vm.getCmsContent = jest.fn();
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(wrapper.vm.$refs.funnelFooter.updateButtonText).toHaveBeenCalled();
|
expect(wrapper.vm.$refs.funnelFooter.updateButtonText).toHaveBeenCalled();
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("Button Text should revert to initial value when registrationZip textfield has new text", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
//Act
|
|
||||||
wrapper.vm.registrationZip = "55555";
|
|
||||||
wrapper.vm.getCmsContent = jest.fn();
|
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
|
||||||
await wrapper.vm.$nextTick();
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(wrapper.vm.$refs.funnelFooter.updateButtonText).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("Button Text should revert to initial value when serviceZip textfield has new text", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
//Act
|
|
||||||
wrapper.vm.serviceZip = "55555";
|
|
||||||
wrapper.vm.getCmsContent = jest.fn();
|
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
|
||||||
await wrapper.vm.$nextTick();
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(wrapper.vm.$refs.funnelFooter.updateButtonText).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("Dispatch reset damage and dependencies should be called if isCarIdDifferent is true and isSelectedGlassAvailableForVehicle is false when updateCustomerInfo is called", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
//Act
|
|
||||||
wrapper.vm.isCarIdDifferent = true;
|
|
||||||
wrapper.vm.isSelectedGlassAvailableForVehicle = false;
|
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
|
||||||
return '';
|
|
||||||
});
|
});
|
||||||
store.commit = jest.fn();
|
|
||||||
store.dispatch = jest.fn();
|
|
||||||
|
|
||||||
const vehicleInfo = {year: "2020", make: "honda", model: "civic", style: "2 door", carId: "TestId", category: "testCat", imageUrl: "image.jpg", imageVifNumber: "123", imageColor: "blue"}
|
test("Button Text should revert to initial value when registrationZip textfield has new text", async () => {
|
||||||
await wrapper.vm.updateCustomerInfo('vin', vehicleInfo, 'registrationState');
|
|
||||||
|
|
||||||
//Assert
|
// Arrange
|
||||||
expect(store.dispatch).toHaveBeenCalled();
|
const { wrapper } = setupMocks({});
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
//Act
|
||||||
test("NavigateAfterSave should be called if isCarIdDifferent is true and isSelectedGlassAvailableForVehicle is false when navigateForward is called", async () => {
|
wrapper.vm.registrationZip = "55555";
|
||||||
|
wrapper.vm.getCmsContent = jest.fn();
|
||||||
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
// Arrange
|
//Assert
|
||||||
const { wrapper } = setupMocks({});
|
expect(wrapper.vm.$refs.funnelFooter.updateButtonText).toHaveBeenCalled();
|
||||||
|
|
||||||
//Act
|
|
||||||
wrapper.vm.isCarIdDifferent = true;
|
|
||||||
wrapper.vm.isSelectedGlassAvailableForVehicle = false;
|
|
||||||
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
|
||||||
return '';
|
|
||||||
});
|
});
|
||||||
store.dispatch = jest.fn();
|
|
||||||
|
|
||||||
await wrapper.vm.navigateForward();
|
test("Button Text should revert to initial value when serviceZip textfield has new text", async () => {
|
||||||
|
|
||||||
//Assert
|
// Arrange
|
||||||
expect(wrapper.vm.$router.navigateAfterSave).toHaveBeenCalled();
|
const { wrapper } = setupMocks({});
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
//Act
|
||||||
test("navigateAfterSaveToHeritageFunnel should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => {
|
wrapper.vm.serviceZip = "55555";
|
||||||
|
wrapper.vm.getCmsContent = jest.fn();
|
||||||
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
// Arrange
|
//Assert
|
||||||
const { wrapper } = setupMocks({});
|
expect(wrapper.vm.$refs.funnelFooter.updateButtonText).toHaveBeenCalled();
|
||||||
|
|
||||||
//Act
|
|
||||||
wrapper.vm.isCarIdDifferent = false;
|
|
||||||
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
|
||||||
return '';
|
|
||||||
});
|
});
|
||||||
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
})
|
||||||
await wrapper.vm.navigateForward();
|
|
||||||
|
|
||||||
//Assert
|
describe("miscellaneous", () => {
|
||||||
expect(navigateToHeritage.navigateAfterSaveToHeritageFunnel).toHaveBeenCalled();
|
test("CarId set, arePagePrerequisitesValid should be true ", async () => {
|
||||||
});
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
licensePlateLookup.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { fmgPage: "license-plate-lookup" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
|
||||||
|
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(arePagePrerequisitesValid).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Dispatch reset damage and dependencies should be called if isCarIdDifferent is true and isSelectedGlassAvailableForVehicle is false when updateCustomerInfo is called", async () => {
|
||||||
|
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
wrapper.vm.isCarIdDifferent = true;
|
||||||
|
wrapper.vm.isSelectedGlassAvailableForVehicle = false;
|
||||||
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
store.commit = jest.fn();
|
||||||
|
store.dispatch = jest.fn();
|
||||||
|
|
||||||
|
const vehicleInfo = { year: "2020", make: "honda", model: "civic", style: "2 door", carId: "TestId", category: "testCat", imageUrl: "image.jpg", imageVifNumber: "123", imageColor: "blue" }
|
||||||
|
await wrapper.vm.updateCustomerInfo('vin', vehicleInfo, 'registrationState');
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(store.dispatch).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("dispatch non blocking store action called on validate zip", async () => {
|
||||||
|
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
await wrapper.vm.validateZip("12345");
|
||||||
|
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("dispatch non blocking store action called on lookup vin", async () => {
|
||||||
|
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
await wrapper.vm.lookupVin("zzz123fqsfwg");
|
||||||
|
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("dispatch non blocking store action called on validate zip", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
//Act
|
|
||||||
await wrapper.vm.validateZip("12345");
|
|
||||||
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("license-plate-lookup.vue", () => {
|
|
||||||
test("dispatch non blocking store action called on lookup vin", async () => {
|
|
||||||
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
//Act
|
|
||||||
await wrapper.vm.lookupVin("zzz123fqsfwg");
|
|
||||||
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function setupMocks({
|
function setupMocks({
|
||||||
pageHeaderWidgetHeaderText = {},
|
pageHeaderWidgetHeaderText = {},
|
||||||
mountOptionsMockData = {
|
mountOptionsMockData = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue