diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js index 1cca562d7..d83f49643 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js +++ b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js @@ -53,7 +53,7 @@ describe("license-plate-lookup.vue", () => { // Arrange const mockRegistrationZip = "77777"; const { wrapper } = setupMocks({ registrationZipCode: mockRegistrationZip }); - + // ACT const registrationZip = wrapper.vm.getRegistrationZipFromStore(); @@ -64,7 +64,7 @@ describe("license-plate-lookup.vue", () => { test("getEmailFromStore returns store customer email", async () => { // Arrange const mockEmail = "test12345@test.com"; - const { wrapper } = setupMocks({emailAddress: mockEmail}); + const { wrapper } = setupMocks({ emailAddress: mockEmail }); // ACT const customerEmail = wrapper.vm.getEmailFromStore(); @@ -75,8 +75,8 @@ describe("license-plate-lookup.vue", () => { test("getServiceZipFromStore returns store service zip", async () => { // Arrange - const { wrapper } = setupMocks({ serviceLocationZipCode: '98765' }); - + const { wrapper } = setupMocks({ serviceLocationZipCode: "98765" }); + // ACT const serviceZip = wrapper.vm.getServiceZipFromStore(); @@ -108,9 +108,14 @@ describe("license-plate-lookup.vue", () => { test("Navigate forward should be called and isCarIdDifferent should be set to false when data entered matches store data on forwardButtonAction click", async () => { // Arrange const mockCarId = "TESTID"; - const { wrapper } = setupMocks({ - carId: mockCarId, - validateZipResponse: { isServiceable: true, isValid: true, zipCodeCtu: "01820", state: "OH" } + const { wrapper } = setupMocks({ + carId: mockCarId, + validateZipResponse: { + isServiceable: true, + isValid: true, + zipCodeCtu: "01820", + state: "OH", + }, }); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ""); @@ -178,9 +183,14 @@ describe("license-plate-lookup.vue", () => { 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({ - carId: "C10000", - validateZipResponse: { isServiceable: true, isValid: true, zipCodeCtu: "01820", state: "OH" } + const { wrapper } = setupMocks({ + carId: "C10000", + validateZipResponse: { + isServiceable: true, + isValid: true, + zipCodeCtu: "01820", + state: "OH", + }, }); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => { @@ -341,14 +351,19 @@ describe("license-plate-lookup.vue", () => { describe("saving registrationZip and serviceZip on continue", () => { test("registrationZip is serviceable and vehicle match is found => sets service zip/state to registration zip/state", async () => { - // NEEDS FIX - Unsure what this test should be doing but it seems incorrect or at least very confusing. If you + // NEEDS FIX - Unsure what this test should be doing but it seems incorrect or at least very confusing. If you // comment out the "Act" entirely, then the test passes which seems to say the test isn't testing anything - + // Arrange - const { wrapper } = setupMocks({ - validateZipResponse: { isServiceable: true, isValid: true, zipCodeCtu: "01820", state: "OH" }, - serviceLocationZipCode: "12345", - registrationZipCode: "12345" + const { wrapper } = setupMocks({ + validateZipResponse: { + isServiceable: true, + isValid: true, + zipCodeCtu: "01820", + state: "OH", + }, + serviceLocationZipCode: "12345", + registrationZipCode: "12345", }); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ""); @@ -357,11 +372,11 @@ describe("license-plate-lookup.vue", () => { navigateToHeritage.navigateToHeritageFunnel = jest.fn(); wrapper.vm.lookupVinByPlate = jest.fn(() => { - return { data: { vehicle: { carId: "C00000", } } } + return { data: { vehicle: { carId: "C00000" } } }; }); storeMutations.lookupVinByPlate = jest.fn().mockImplementation(() => { - return { data: { vehicle: { carId: "C00000", } } } + return { data: { vehicle: { carId: "C00000" } } }; }); wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => @@ -381,7 +396,7 @@ describe("license-plate-lookup.vue", () => { expect(wrapper.vm.$store.getters.order.serviceLocation.zipCode).toEqual( wrapper.vm.$store.getters.vehicle.registration.zipCode ); - + expect(wrapper.vm.$store.getters.vehicle.registration.zipCode).toEqual("12345"); expect(wrapper.vm.$store.getters.order.serviceLocation.zipCode).toEqual("12345"); }); @@ -389,10 +404,10 @@ describe("license-plate-lookup.vue", () => { test("vehicle match is found but registrationZip is not serviceable => shows service zip/state field", async () => { // Arrange // TODO FIX - seems like shouldn't have to set serviceLocationZipCode or registrationZipCode in state from the start - const { wrapper } = setupMocks({ + const { wrapper } = setupMocks({ validateZipResponse: { isServiceable: false, isValid: true }, - serviceLocationZipCode: "12345", - registrationZipCode: "12345" + serviceLocationZipCode: "12345", + registrationZipCode: "12345", }); // TODO FIX - test succeeds even if you comment this line out, is it doing anything? wrapper.vm.validateZip = jest.fn().mockImplementation(() => { @@ -411,7 +426,7 @@ describe("license-plate-lookup.vue", () => { }, }) ); - + //TODO FIX - test succeeds even if comment out the Act section // Act await wrapper.vm.forwardButtonAction(); @@ -465,17 +480,17 @@ describe("license-plate-lookup.vue", () => { test("registrationZip is not serviceable so serviceZip field is shown, user enters serviceZip => user can continue", async () => { // Arrange - const { wrapper } = setupMocks({ - validateZipResponse: { isServiceable: false, isValid: true } + const { wrapper } = setupMocks({ + validateZipResponse: { isServiceable: false, isValid: true }, }); const registrationZip = "00000"; const serviceZip = "99999"; wrapper.vm.navigateForward = jest.fn(); - - const vinLookup = { data: { vehicle: { carId: "TESTID1" } } } + + const vinLookup = { data: { vehicle: { carId: "TESTID1" } } }; wrapper.vm.lookupVin = jest.fn().mockImplementation(() => { - return new Promise(resolve => resolve(vinLookup)); + return new Promise((resolve) => resolve(vinLookup)); }); await wrapper.setData({ registrationZipCode: registrationZip }); @@ -503,19 +518,19 @@ describe("license-plate-lookup.vue", () => { // TODO FIX - This test only works because 12345 is set in the state store when setupMocks is called. If u change registrationZip or serviceZip // to any other value, then the test fails. Driving this home is you can comment out the entire "Act" portion (and the expect navigate forward be called)' // and the test still succeeds so the checking ZIP fields part doesn't work. - const { wrapper } = setupMocks({ + const { wrapper } = setupMocks({ validateZipResponse: { isServiceable: false, isValid: true }, - //serviceLocationZipCode: "12345", - //registrationZipCode: "12345" + //serviceLocationZipCode: "12345", + //registrationZipCode: "12345" }); const registrationZip = "12345"; const serviceZip = "12345"; console.log("this is the test I care about"); wrapper.vm.navigateForward = jest.fn(); - const vinLookup = { data: { vehicle: { carId: "TESTID1" } } } + const vinLookup = { data: { vehicle: { carId: "TESTID1" } } }; wrapper.vm.lookupVin = jest.fn().mockImplementation(() => { - return new Promise(resolve => resolve(vinLookup)); + return new Promise((resolve) => resolve(vinLookup)); }); await wrapper.setData({ registrationZipCode: registrationZip }); @@ -529,7 +544,7 @@ describe("license-plate-lookup.vue", () => { isValid: true, isServiceable: true, state: "OH", - zipCodeCtu: "01820", + zipCodeCtu: "01820", }, registrationZipValidationResponse: { isValid: true, @@ -550,7 +565,7 @@ describe("license-plate-lookup.vue", () => { // TODO - these two values have a value in pages "data" but not setting it in store; need to figure out why or mock it or something //expect(wrapper.vm.$store.vehicle.registration.zipCode).toEqual(registrationZip); //expect(wrapper.vm.$store.order.serviceLocation.zipCode).toEqual(serviceZip); - + //Verify we only navigateForward one time despite our calling forwardButtonAction twice expect(wrapper.vm.navigateForward).toBeCalledTimes(1); }); @@ -608,7 +623,7 @@ function setupMocks({ serviceLocationZipCode = null, registrationZipCode = null, licensePlate = null, //"TESTPLATE", - emailAddress = null //"test@test.com" + emailAddress = null, //"test@test.com" }) { store.commit(storeMutations.RESET_STATE); //Mock api responses @@ -628,7 +643,7 @@ function setupMocks({ isValid: validateZipResponse.isValid, isServiceable: validateZipResponse.isServiceable, state: validateZipResponse.state, - zipCodeCtu: validateZipResponse.zipCodeCtu, + zipCodeCtu: validateZipResponse.zipCodeCtu, }, registrationZipValidationResponse: { isValid: validateZipResponse.isValid, diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index 90f67bc31..159d89260 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -225,14 +225,16 @@ export default { const resultMap = await settleAllPromises(promiseResultMap); // Lookup vin - const vinLookup = await this.lookupVin(this.licensePlate, resultMap.registrationZipValidationResponse.state) - .catch(() => { - // No VIN found. - this.displayVinNotFoundAlert = true; - return this.$refs.funnelFooter.removeLoader(); - }); + const vinLookup = await this.lookupVin( + this.licensePlate, + resultMap.registrationZipValidationResponse.state + ).catch(() => { + // No VIN found. + this.displayVinNotFoundAlert = true; + return this.$refs.funnelFooter.removeLoader(); + }); // If no VIN was found, stop processing after displaying alert - if (!vinLookup) { + if (!vinLookup) { return; } @@ -312,7 +314,11 @@ export default { return await this.navigateForward(); }, lookupVin(plate, state) { - return this.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE,{ licensePlate: plate, licenseState: state }, false); + return this.dispatchStoreAction( + storeActions.LOOKUP_VIN_BY_PLATE, + { licensePlate: plate, licenseState: state }, + false + ); }, async navigateForward() { if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) { diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 25e69ca2f..3f2a75ebb 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -130,11 +130,11 @@ export default { methods: { arePagePrerequisitesValid() { return ( - (store.getters.order.serviceLocation.zipCode && store.getters.order.serviceLocation.zipCodeCtu) - && + store.getters.order.serviceLocation.zipCode && + store.getters.order.serviceLocation.zipCodeCtu && (store.getters.order.damage.isRepair || - (store.getters.order.lineItems?.glassParts != null && - store.getters.order.lineItems.glassParts.length > 0)) + (store.getters.order.lineItems?.glassParts != null && + store.getters.order.lineItems.glassParts.length > 0)) ); }, getDefaultIsInsuranceSelectedValue() { diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 88fc09ff9..06f0cb746 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -322,11 +322,11 @@ describe("Mutations", () => { zipCode: "43212", state: "OH", zipCodeCtu: "01820", - } + }; // Act mutations.updateServiceLocation(storeState, serviceLocation); - + // Assert expect(storeState.order.serviceLocation.address).toEqual("123 Test Lane"); expect(storeState.order.serviceLocation.city).toEqual("Columbus"); @@ -491,11 +491,11 @@ describe("Actions", () => { globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { - "isValid": true, - "isServiceable": true, - "state": "OH", - "zipCodeCtu": "01820" - } + isValid: true, + isServiceable: true, + state: "OH", + zipCodeCtu: "01820", + }, }); }); @@ -503,10 +503,10 @@ describe("Actions", () => { // Assert expect(response.data).toEqual({ - "isValid": true, - "isServiceable": true, - "state": "OH", - "zipCodeCtu": "01820" + isValid: true, + isServiceable: true, + state: "OH", + zipCodeCtu: "01820", }); }); @@ -912,7 +912,7 @@ describe("Actions", () => { zipCode: "43212", state: "OH", zipCodeCtu: "01820", - } + }; // Act actions.saveServiceLocation(context, serviceLocation);