From 20cb89ed8decbead0e593550389f4d1e897adf0e Mon Sep 17 00:00:00 2001 From: DavidAtSafelite Date: Wed, 26 Jul 2023 13:47:35 -0400 Subject: [PATCH] Linting for first 10 layouts --- .../address-lookup/address-lookup.spec.js | 182 +++++----- src/layouts/address-lookup/address-lookup.vue | 286 ++++++++-------- .../customer-questions.spec.js | 25 +- .../customer-questions/customer-questions.vue | 30 +- .../address-vehicles-question.spec.js | 78 +++-- .../address-vehicles-question.vue | 61 ++-- .../address-vehicles/address-vehicles.spec.js | 208 ++++++------ .../address-vehicles/address-vehicles.vue | 180 +++++----- src/layouts/bailout-page/bailout-page.vue | 47 +-- .../capability-questions.spec.js | 304 ++++++++--------- .../capability-questions.vue | 88 +++-- .../contact-details/contact-details.spec.js | 6 +- .../coverage-statement.spec.js | 18 +- .../coverage-statement/coverage-statement.vue | 5 +- .../recal-modal/recal-modal.spec.js | 42 ++- .../recal-modal/recal-modal.vue | 48 +-- src/layouts/entry-page/entry-page.spec.js | 35 +- src/layouts/entry-page/entry-page.vue | 71 ++-- .../license-plate-lookup.spec.js | 197 +++++------ .../license-plate-lookup.vue | 301 ++++++++--------- .../molding-questions.spec.js | 316 +++++++++--------- .../molding-questions/molding-questions.vue | 101 +++--- .../order-confirmation/order-confirmation.vue | 39 ++- 23 files changed, 1268 insertions(+), 1400 deletions(-) diff --git a/src/layouts/address-lookup/address-lookup.spec.js b/src/layouts/address-lookup/address-lookup.spec.js index 3e351878..971a99c6 100644 --- a/src/layouts/address-lookup/address-lookup.spec.js +++ b/src/layouts/address-lookup/address-lookup.spec.js @@ -1,5 +1,5 @@ // Components -import addressLookup from '@/layouts/address-lookup/address-lookup.vue'; +import addressLookup from '@/layouts/address-lookup/address-lookup'; // Supporting Files import { settleAllPromises } from '@/helpers/layout-helper.js'; @@ -18,6 +18,79 @@ jest.mock('@/helpers/layout-helper.js', () => ({ settleAllPromises: jest.fn() })); +function setupMocks({ + lookupVinbyAddressResponse, + partsOrQuestions = [], + isStatePermissible = true, + vinVehicles = [], + carId = 'C0000', + route = null +}) { + useMainStore().lookupVinByAddress = jest.fn().mockImplementation(() => Promise.resolve({ + data: lookupVinbyAddressResponse || { + isStatePermissible: true, + vinVehicles: [ + { + vin: 'TEST_VIN', + vehicle: { + carId: 'CARID' + } + } + ] + } + })); + + useMainStore().getPartsOrQuestions = jest.fn().mockImplementation(() => Promise.resolve({ + data: { + partsOrQuestions + } + })); + + const wrapper = shallowMount(addressLookup, + getMountOptions({ + route: route || undefined, + router: { + navigate: jest.fn() + }, + mainStore: { + order: { + vehicle: { + carId, + registration: { + licensePlate: 'TESTPLATE', + zipCode: '12345' + } + }, + customer: { + emailAddress: 'test@test.com' + }, + serviceLocation: { + zipCode: '11111' + } + } + } + + })); + + const apiResponses = { + vinLookupResponse: { + isStatePermissible, + vinVehicles + } + }; + + settleAllPromises.mockImplementation(() => apiResponses); + + wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ''); + wrapper.vm.setCmsContent = jest.fn(); + wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn(); + wrapper.vm.$refs.siteFooter.removeLoader = jest.fn(); + wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn(); + wrapper.vm.$refs.siteFooter.enableForwardAction = jest.fn(); + + return { wrapper }; +} + describe('address-lookup.vue', () => { describe('page level alerts', () => { test('if the address matches a different vehicle display the Matched Different VehicleAlert', async () => { @@ -51,9 +124,7 @@ describe('address-lookup.vue', () => { await wrapper.vm.forwardButtonAction(); // Assert - expect(wrapper.findComponent({ ref: 'alertMatchedDifferentVehicle' }).isVisible()).toBe( - true - ); + expect(wrapper.findComponent({ ref: 'alertMatchedDifferentVehicle' }).isVisible()).toBe(true); }); test('if the address matches two identical YMM vehicles, then display Two Identical YMM Vehicle alert', async () => { @@ -88,9 +159,7 @@ describe('address-lookup.vue', () => { await wrapper.vm.forwardButtonAction(); // Assert - expect(wrapper.findComponent({ ref: 'alertMatchedTwoIdenticalYMMVehicle' }).isVisible()).toBe( - true - ); + expect(wrapper.findComponent({ ref: 'alertMatchedTwoIdenticalYMMVehicle' }).isVisible()).toBe(true); }); test('if the looking up VIN by address is not allowed in the state selected display the Vin Lookup By HomeAddress Not Allowed Alert', async () => { @@ -135,9 +204,7 @@ describe('address-lookup.vue', () => { await wrapper.vm.forwardButtonAction(); // Assert - expect( - wrapper.findComponent({ ref: 'alertVinLookupsByHomeAddressNotAllowed' }).isVisible() - ).toBe(true); + expect(wrapper.findComponent({ ref: 'alertVinLookupsByHomeAddressNotAllowed' }).isVisible()).toBe(true); }); test('if no vehicles found, display Vin Not Found alert', async () => { @@ -278,13 +345,11 @@ describe('address-lookup.vue', () => { await wrapper.vm.forwardButtonAction(); // Assert - expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( - navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES, + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES, undefined, {}, {}, - carsFound - ); + carsFound); }); test('if a different vehicle is found than the one entered and the selected glass is not available for that vehicle, navigate back to vehicle-damage page', async () => { @@ -310,7 +375,7 @@ describe('address-lookup.vue', () => { useMainStore().order.vehicle.carId = 'CARID'; - let carsFound = [ + const carsFound = [ { vin: 'TEST_VIN2', vehicle: { @@ -323,12 +388,10 @@ describe('address-lookup.vue', () => { await wrapper.vm.navigateForward(carsFound); // Assert - expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( - navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, undefined, {}, - { displayVehicleChangeAlert: true } - ); + { displayVehicleChangeAlert: true }); }); test('single car was found and matches entered vehicle => navigateForwardWithSingleCarMatch', async () => { @@ -391,84 +454,3 @@ describe('address-lookup.vue', () => { }); }); }); - -function setupMocks({ - lookupVinbyAddressResponse, - partsOrQuestions = [], - isStatePermissible = true, - vinVehicles = [], - carId = 'C0000', - route = null -}) { - useMainStore().lookupVinByAddress = jest.fn().mockImplementation(() => { - return Promise.resolve({ - data: lookupVinbyAddressResponse - ? lookupVinbyAddressResponse - : { - isStatePermissible: true, - vinVehicles: [ - { - vin: 'TEST_VIN', - vehicle: { - carId: 'CARID' - } - } - ] - } - }); - }); - - useMainStore().getPartsOrQuestions = jest.fn().mockImplementation(() => { - return Promise.resolve({ - data: { - partsOrQuestions: partsOrQuestions - } - }); - }); - - const wrapper = shallowMount( - addressLookup, - getMountOptions({ - route: route ? route : undefined, - router: { - navigate: jest.fn() - }, - mainStore: { - order: { - vehicle: { - carId: carId, - registration: { - licensePlate: 'TESTPLATE', - zipCode: '12345' - } - }, - customer: { - emailAddress: 'test@test.com' - }, - serviceLocation: { - zipCode: '11111' - } - } - } - - }) - ); - - const apiResponses = { - vinLookupResponse: { - isStatePermissible: isStatePermissible, - vinVehicles: vinVehicles - } - }; - - settleAllPromises.mockImplementation(() => apiResponses); - - wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ''); - wrapper.vm.setCmsContent = jest.fn(); - wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn(); - wrapper.vm.$refs.siteFooter.removeLoader = jest.fn(); - wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn(); - wrapper.vm.$refs.siteFooter.enableForwardAction = jest.fn(); - - return { wrapper }; -} diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index c486dc08..b69f99ce 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -1,5 +1,9 @@