From 48f704f6ea3ce4c43e05b54e957462efdafc05be Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Thu, 30 Nov 2023 11:12:59 -0500 Subject: [PATCH] add/update tests for navigation --- .../policy-vehicles/policy-vehicles.spec.js | 53 ++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/src/layouts/policy-vehicles/policy-vehicles.spec.js b/src/layouts/policy-vehicles/policy-vehicles.spec.js index 378e9b5f..9f9ca75e 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.spec.js +++ b/src/layouts/policy-vehicles/policy-vehicles.spec.js @@ -140,13 +140,62 @@ describe('policy-vehicles.vue', () => { test( // eslint-disable-next-line max-len - 'Selected VIN matches vehicle listed in system and policy vehicle has endorsements => update vehicle and navigate forward with CLICKED_FORWARD_WITH_ENDORSEMENTS scenario.', + 'Selected VIN matches vehicle listed in system and policy vehicle has Educator endorsement => update vehicle and navigate forward with CLICKED_FORWARD_WITH_ENDORSEMENTS scenario.', async () => { // Arrange const { wrapper } = setupMocks({}); const vin = getRandomString(17, 17); - const endorsements = [getRandomString(10, 20)]; + const endorsements = ['Educator']; + await wrapper.setData({ + selectedVehicleVin: vin, + policyVehicles: [ + { + vin, + endorsements + } + ] + }); + + const year = getRandomInt(1998, 2023); + const lookupVehicleResponse = { + data: { + year + } + }; + const store = useMainStore(); + store.lookupVehicleByVin.mockReturnValue(Promise.resolve(lookupVehicleResponse)); + + const expectedInput = { + year, + vin, + noCoverage: true, + deductible: 0, + repairWaived: false, + endorsements + }; + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(store.updateVehicle).toHaveBeenCalledWith(expectedInput); + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( + navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS, + undefined + ); + } + ); + + test( + // eslint-disable-next-line max-len + 'Selected VIN matches vehicle listed in system and policy vehicle has Parking Guard endorsement => update vehicle and navigate forward with CLICKED_FORWARD_WITH_ENDORSEMENTS scenario.', + async () => { + // Arrange + const { wrapper } = setupMocks({}); + + const vin = getRandomString(17, 17); + const endorsements = ['Parking Guard']; await wrapper.setData({ selectedVehicleVin: vin, policyVehicles: [