diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 8429f3ad..06ecde94 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -162,6 +162,10 @@ const endpoints = Object.freeze({ url: '/order/api/v1/order/save-session/iss', method: 'POST' }, + LoadSession: { + url: '/order/api/v1/order/load-session', + method: 'POST' + }, DuplicateSearch: { // eslint-disable-next-line max-len url: (accountNumber, policyNumber, phoneNumber) => `/order/api/v1/order/duplicate-check/${accountNumber}/${policyNumber}/${phoneNumber}`, diff --git a/src/helpers/text-helper.js b/src/helpers/text-helper.js index 01d18309..d08e0c04 100644 --- a/src/helpers/text-helper.js +++ b/src/helpers/text-helper.js @@ -5,7 +5,21 @@ * @param {string} stringWithStyleTag * @returns {string} */ -export default function stripRteStyle(stringWithStyleTag) { +export function stripRteStyle(stringWithStyleTag) { const regexExp = /[\s*]style="(.*?)"/g; return stringWithStyleTag.replace(regexExp, ''); } + +/** + * @function toTitleCase + * @summary Returns title cased string version of 'text' + * @param {string} text + * @returns {string} + */ +export function toTitleCase(text) { + const temp = text.toLowerCase().split(' '); + for (let i = 0; i < temp.length; i++) { + temp[i] = temp[i].charAt(0).toUpperCase() + temp[i].slice(1); + } + return temp.join(' '); +} diff --git a/src/layouts/contact-details/contact-details.spec.js b/src/layouts/contact-details/contact-details.spec.js index c6938e58..0b133e22 100644 --- a/src/layouts/contact-details/contact-details.spec.js +++ b/src/layouts/contact-details/contact-details.spec.js @@ -1,11 +1,11 @@ // Components +import { shallowMount } from '@vue/test-utils'; +import { createTestingPinia } from '@pinia/testing'; import contactDetails from '@/layouts/contact-details/contact-details.vue'; // Supporting Files -import { shallowMount } from '@vue/test-utils'; import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getRandomString, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js'; -import { createTestingPinia } from '@pinia/testing'; import navigationScenarios from '@/router/router-constants/navigation-scenarios.js'; import { useMainStore } from '@/store/index.js'; @@ -267,9 +267,6 @@ describe('contactDetails.vue', () => { const mountOptions = getMountOptions({ router: { navigate: jest.fn() - }, - global: { - plugins: [createTestingPinia()] } }); const wrapper = shallowMount(contactDetails, mountOptions); @@ -302,4 +299,89 @@ describe('contactDetails.vue', () => { }); }); }); + + test('Mocked store with no contact info yields expected data', () => { + // Arrange + const mountOptions = getMountOptions(); + + const firstName = getRandomString(4, 15); + const lastName = getRandomString(4, 15); + const emailAddress = getRandomString(10, 20); + const phoneNumber = getRandomInt(1000000000, 9999999999); + const mainInitialState = { + order: { + customer: { + firstName, + lastName, + emailAddress, + phoneNumber + }, + contactInfo: { + firstName: null, + lastName: null, + emailAddress: null, + phoneNumber: null, + requestTextUpdates: null, + notesForTechnician: null + } + } + }; + mountOptions.global = { + plugins: [createTestingPinia({ + initialState: { + main: mainInitialState + } + })] + }; + + const wrapper = shallowMount(contactDetails, mountOptions); + + // Assert + expect(wrapper.vm.firstName).toBe(firstName); + expect(wrapper.vm.lastName).toBe(lastName); + expect(wrapper.vm.emailAddress).toBe(emailAddress); + expect(wrapper.vm.phoneNumber).toBe(phoneNumber); + }); + + test('Mock store with contact info yields expected data', () => { + // Arrange + const customer = { + firstName: getRandomString(4, 15), + lastName: getRandomString(4, 15), + emailAddress: getRandomString(10, 20), + phoneNumber: getRandomInt(1000000000, 9999999999) + }; + const contactInfo = { + firstName: getRandomString(4, 15), + lastName: getRandomString(4, 15), + emailAddress: getRandomString(10, 20), + phoneNumber: getRandomInt(1000000000, 9999999999), + requestTextUpdates: getRandomBoolean(), + notesForTechnician: getRandomString(50, 100) + }; + const mainInitialState = { + order: { + customer, + contactInfo + } + }; + const mountOptions = getMountOptions(); + mountOptions.global = { + plugins: [createTestingPinia({ + initialState: { + main: mainInitialState + } + })] + }; + + const wrapper = shallowMount(contactDetails, mountOptions); + + // Assert + expect(wrapper.vm.firstName).toBe(contactInfo.firstName); + expect(wrapper.vm.lastName).toBe(contactInfo.lastName); + expect(wrapper.vm.emailAddress).toBe(contactInfo.emailAddress); + expect(wrapper.vm.phoneNumber).toBe(contactInfo.phoneNumber); + expect(wrapper.vm.requestTextUpdates).toBe(contactInfo.requestTextUpdates); + expect(wrapper.vm.notesForTechnician).toBe(contactInfo.notesForTechnician); + }); }); diff --git a/src/layouts/duplicate-check/duplicate-check.spec.js b/src/layouts/duplicate-check/duplicate-check.spec.js index e0b06650..f9138fe9 100644 --- a/src/layouts/duplicate-check/duplicate-check.spec.js +++ b/src/layouts/duplicate-check/duplicate-check.spec.js @@ -1,12 +1,13 @@ // Components +import { shallowMount } from '@vue/test-utils'; +import { createTestingPinia } from '@pinia/testing'; import duplicateCheck from '@/layouts/duplicate-check/duplicate-check.vue'; // Supporting Files -import { shallowMount } from '@vue/test-utils'; import { getMountOptions } from '@/helpers/unit-test-helper.js'; -import { createTestingPinia } from '@pinia/testing'; import navigationScenarios from '@/router/router-constants/navigation-scenarios.js'; import { getRandomString } from '@/helpers/data-generation.js'; +import { useMainStore } from '@/store'; const duplicateOrderText = 'Finish Existing Claim'; @@ -52,279 +53,277 @@ describe('duplicateCheck.vue', () => { // Assert expect(footer.exists()).toBeTruthy(); }); - - // TODO update or remove - // test('Mocked store with no contact info yields expected data', () => { - // // Arrange - // const mountOptions = getMountOptions(); - - // const firstName = getRandomString(4, 15); - // const lastName = getRandomString(4, 15); - // const emailAddress = getRandomString(10, 20); - // const phoneNumber = getRandomInt(1000000000, 9999999999); - // const mainInitialState = { - // order: { - // customer: { - // firstName, - // lastName, - // emailAddress, - // phoneNumber - // } - // } - // }; - // mountOptions.global = { - // plugins: [createTestingPinia({ - // initialState: { - // main: mainInitialState - // } - // })] - // }; - - // const wrapper = shallowMount(contactDetails, mountOptions); - - // // Assert - // expect(wrapper.vm.firstName).toBe(firstName); - // expect(wrapper.vm.lastName).toBe(lastName); - // expect(wrapper.vm.emailAddress).toBe(emailAddress); - // expect(wrapper.vm.phoneNumber).toBe(phoneNumber); - // }); - // test('Mock store with contact info yields expected data', () => { - // // Arrange - // const customer = { - // firstName: getRandomString(4, 15), - // lastName: getRandomString(4, 15), - // emailAddress: getRandomString(10, 20), - // phoneNumber: getRandomInt(1000000000, 9999999999) - // }; - // const contactInfo = { - // firstName: getRandomString(4, 15), - // lastName: getRandomString(4, 15), - // emailAddress: getRandomString(10, 20), - // phoneNumber: getRandomInt(1000000000, 9999999999), - // requestTextUpdates: getRandomBoolean(), - // notesForTechnician: getRandomString(50, 100) - // }; - // const mainInitialState = { - // order: { - // customer, - // contactInfo - // } - // }; - // const mountOptions = getMountOptions(); - // mountOptions.global = { - // plugins: [createTestingPinia({ - // initialState: { - // main: mainInitialState - // } - // })] - // }; - - // const wrapper = shallowMount(contactDetails, mountOptions); - - // // Assert - // expect(wrapper.vm.firstName).toBe(contactInfo.firstName); - // expect(wrapper.vm.lastName).toBe(contactInfo.lastName); - // expect(wrapper.vm.emailAddress).toBe(contactInfo.emailAddress); - // expect(wrapper.vm.phoneNumber).toBe(contactInfo.phoneNumber); - // expect(wrapper.vm.requestTextUpdates).toBe(contactInfo.requestTextUpdates); - // expect(wrapper.vm.notesForTechnician).toBe(contactInfo.notesForTechnician); - // }); }); - describe('duplicateOrders computed', () => { - test('duplicateOrders in store undefined => returns empty list', () => { - // Arrange - const mountOptions = getMountOptions({ - router: { navigate: jest.fn() } + describe('computed properties', () => { + describe('duplicateOrders computed', () => { + test('duplicateOrders in store undefined => returns empty list', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + + const mainInitialState = { + applicationUser: { + duplicateOrders: undefined + } + }; + mountOptions.global.plugins = [createTestingPinia({ + initialState: { + main: mainInitialState + } + })]; + + const wrapper = shallowMount(duplicateCheck, mountOptions); + + // Assert + expect(wrapper.vm.duplicateOrders.length).toBe(0); }); + test('duplicateOrders in store empty => returns empty list', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); - const mainInitialState = { - applicationUser: { - duplicateOrders: undefined - } - }; - mountOptions.global.plugins = [createTestingPinia({ - initialState: { - main: mainInitialState - } - })]; + const mainInitialState = { + applicationUser: { + duplicateOrders: [] + } + }; + mountOptions.global.plugins = [createTestingPinia({ + initialState: { + main: mainInitialState + } + })]; - const wrapper = shallowMount(duplicateCheck, mountOptions); + const wrapper = shallowMount(duplicateCheck, mountOptions); - // Assert - expect(wrapper.vm.duplicateOrders.length).toBe(0); - }); - test('duplicateOrders in store empty => returns empty list', () => { - // Arrange - const mountOptions = getMountOptions({ - router: { navigate: jest.fn() } + // Assert + expect(wrapper.vm.duplicateOrders.length).toBe(0); }); + test('duplicateOrder in store with null vehicle year => returns order with only date in subtext', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); - const mainInitialState = { - applicationUser: { - duplicateOrders: [] - } - }; - mountOptions.global.plugins = [createTestingPinia({ - initialState: { - main: mainInitialState - } - })]; + const referralNumber = getRandomString(6, 6); + const mainInitialState = { + applicationUser: { + duplicateOrders: [ + { + vehicleYear: null, + vehicleMake: getRandomString(5, 5), + vehicleModel: getRandomString(5, 5), + responseDate: '1990-09-23T01:12:34', + referralNumber + } + ] + } + }; + mountOptions.global.plugins = [createTestingPinia({ + initialState: { + main: mainInitialState + } + })]; + const expectedSubtext = '9/23/1990'; - const wrapper = shallowMount(duplicateCheck, mountOptions); + const wrapper = shallowMount(duplicateCheck, mountOptions); - // Assert - expect(wrapper.vm.duplicateOrders.length).toBe(0); - }); - test('duplicateOrder in store with null vehicle year => returns order with only date in subtext', () => { - // Arrange - const mountOptions = getMountOptions({ - router: { navigate: jest.fn() } + // Assert + expect(wrapper.vm.duplicateOrders.length).toBe(1); + expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({ + Text: duplicateOrderText, + Name: referralNumber, + SubText: expectedSubtext + }); }); + test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); - const date = getRandomString(9, 9); - const referralNumber = getRandomString(6, 6); - const mainInitialState = { - applicationUser: { - duplicateOrders: [ - { - vehicleYear: null, - vehicleMake: getRandomString(5, 5), - vehicleModel: getRandomString(5, 5), - dateOfLoss: date, - referralNumber - } - ] - } - }; - mountOptions.global.plugins = [createTestingPinia({ - initialState: { - main: mainInitialState - } - })]; + const referralNumber = getRandomString(6, 6); + const mainInitialState = { + applicationUser: { + duplicateOrders: [ + { + vehicleYear: getRandomString(6, 6), + vehicleMake: null, + vehicleModel: getRandomString(5, 5), + responseDate: '2004-11-01T01:12:34', + referralNumber + } + ] + } + }; + mountOptions.global.plugins = [createTestingPinia({ + initialState: { + main: mainInitialState + } + })]; + const expectedSubtext = '11/1/2004'; - const wrapper = shallowMount(duplicateCheck, mountOptions); + const wrapper = shallowMount(duplicateCheck, mountOptions); - // Assert - expect(wrapper.vm.duplicateOrders.length).toBe(1); - expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({ - Text: duplicateOrderText, - Name: referralNumber, - SubText: date + // Assert + expect(wrapper.vm.duplicateOrders.length).toBe(1); + expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({ + Text: duplicateOrderText, + Name: referralNumber, + SubText: expectedSubtext + }); + }); + test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + + const referralNumber = getRandomString(6, 6); + const mainInitialState = { + applicationUser: { + duplicateOrders: [ + { + vehicleYear: getRandomString(6, 6), + vehicleMake: getRandomString(6, 6), + vehicleModel: null, + responseDate: '1999-01-15T01:12:34', + referralNumber + } + ] + } + }; + mountOptions.global.plugins = [createTestingPinia({ + initialState: { + main: mainInitialState + } + })]; + const expectedSubtext = '1/15/1999'; + + const wrapper = shallowMount(duplicateCheck, mountOptions); + + // Assert + expect(wrapper.vm.duplicateOrders.length).toBe(1); + expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({ + Text: duplicateOrderText, + Name: referralNumber, + SubText: expectedSubtext + }); + }); + test('duplicateOrder in store with all vehicle info => returns order with year, make, model and date in subtext', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + + const referralNumber = getRandomString(6, 6); + const mainInitialState = { + applicationUser: { + duplicateOrders: [ + { + vehicleYear: 'YEAR', + vehicleMake: 'make', + vehicleModel: 'MoDel', + responseDate: '2018-03-01T01:12:34', + referralNumber + } + ] + } + }; + mountOptions.global.plugins = [createTestingPinia({ + initialState: { + main: mainInitialState + } + })]; + const expectedVehicle = 'Year Make Model'; + const expectedDate = '3/1/2018'; + + const wrapper = shallowMount(duplicateCheck, mountOptions); + + // Assert + expect(wrapper.vm.duplicateOrders.length).toBe(1); + expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({ + Text: duplicateOrderText, + Name: referralNumber, + SubText: `${expectedVehicle}, ${expectedDate}` + }); }); }); - test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => { - // Arrange - const mountOptions = getMountOptions({ - router: { navigate: jest.fn() } + describe('getNewOrderSelectionName', () => { + test('answersFromCms null => returns empty string', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + const answersFromCmsValue = null; + mountOptions.mixins = [{ + methods: { + getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers' ? answersFromCmsValue : '')) + } + }]; + + const wrapper = shallowMount(duplicateCheck, mountOptions); + + // Assert + expect(wrapper.vm.getNewOrderSelectionName).toBe(''); }); + test('answersFromCms empty list => returns empty string', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + const answersFromCmsValue = []; + mountOptions.mixins = [{ + methods: { + getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers' ? answersFromCmsValue : '')) + } + }]; - const date = getRandomString(9, 9); - const referralNumber = getRandomString(6, 6); - const mainInitialState = { - applicationUser: { - duplicateOrders: [ - { - vehicleYear: getRandomString(6, 6), - vehicleMake: null, - vehicleModel: getRandomString(5, 5), - dateOfLoss: date, - referralNumber: referralNumber - } - ] - } - }; - mountOptions.global.plugins = [createTestingPinia({ - initialState: { - main: mainInitialState - } - })]; + const wrapper = shallowMount(duplicateCheck, mountOptions); - const wrapper = shallowMount(duplicateCheck, mountOptions); - - // Assert - expect(wrapper.vm.duplicateOrders.length).toBe(1); - expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({ - Text: duplicateOrderText, - Name: referralNumber, - SubText: date + // Assert + expect(wrapper.vm.getNewOrderSelectionName).toBe(''); }); - }); - test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => { - // Arrange - const mountOptions = getMountOptions({ - router: { navigate: jest.fn() } + test('answersFromCms non-empty list whose first item has no Name property => returns empty string', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + const answersFromCmsValue = [{ test: getRandomString(6, 6) }]; + mountOptions.mixins = [{ + methods: { + getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers' + ? answersFromCmsValue + : '')) + } + }]; + + const wrapper = shallowMount(duplicateCheck, mountOptions); + + // Assert + expect(wrapper.vm.getNewOrderSelectionName).toBe(''); }); + test('answersFromCms first item has Name property => returns expected', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + const expectedName = getRandomString(6, 6); + const answersFromCmsValue = [{ Name: expectedName }]; + mountOptions.mixins = [{ + methods: { + getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers' + ? answersFromCmsValue + : '')) + } + }]; - const date = getRandomString(9, 9); - const referralNumber = getRandomString(6, 6); - const mainInitialState = { - applicationUser: { - duplicateOrders: [ - { - vehicleYear: getRandomString(6, 6), - vehicleMake: getRandomString(6, 6), - vehicleModel: null, - dateOfLoss: date, - referralNumber: referralNumber - } - ] - } - }; - mountOptions.global.plugins = [createTestingPinia({ - initialState: { - main: mainInitialState - } - })]; + const wrapper = shallowMount(duplicateCheck, mountOptions); - const wrapper = shallowMount(duplicateCheck, mountOptions); - - // Assert - expect(wrapper.vm.duplicateOrders.length).toBe(1); - expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({ - Text: duplicateOrderText, - Name: referralNumber, - SubText: date - }); - }); - test('duplicateOrder in store with all vehicle info => returns order with year, make, model and date in subtext', () => { - // Arrange - const mountOptions = getMountOptions({ - router: { navigate: jest.fn() } - }); - - const year = getRandomString(6, 6,); - const make = getRandomString(6, 6); - const model = getRandomString(6, 6); - const date = getRandomString(9, 9); - const referralNumber = getRandomString(6, 6); - const mainInitialState = { - applicationUser: { - duplicateOrders: [ - { - vehicleYear: year, - vehicleMake: make, - vehicleModel: model, - dateOfLoss: date, - referralNumber: referralNumber - } - ] - } - }; - mountOptions.global.plugins = [createTestingPinia({ - initialState: { - main: mainInitialState - } - })]; - - const wrapper = shallowMount(duplicateCheck, mountOptions); - - // Assert - expect(wrapper.vm.duplicateOrders.length).toBe(1); - expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({ - Text: duplicateOrderText, - Name: referralNumber, - SubText: `${year} ${make} ${model}, ${date}` + // Assert + expect(wrapper.vm.getNewOrderSelectionName).toBe(expectedName); }); }); }); @@ -348,7 +347,88 @@ describe('duplicateCheck.vue', () => { }); describe('forwardButtonAction', () => { - test('policyLookupSuccessful true and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', () => { + test('Selected duplicate => load session called', async () => { + // Arrange + const newOrderSelectionName = getRandomString(6, 6); + const selectedAnswer = getRandomString(6, 6); + + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + mountOptions.mixins = [{ + methods: { + getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers' + ? [{ Name: newOrderSelectionName }] + : '')) + } + }]; + + const wrapper = shallowMount(duplicateCheck, mountOptions); + wrapper.setData({ selectedAnswer }); + useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({})); + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.mainStore.loadSession).toHaveBeenCalledTimes(1); + expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); + }); + test('Selected new order => load session not called', async () => { + // Arrange + const newOrderSelectionName = getRandomString(6, 6); + + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + mountOptions.mixins = [{ + methods: { + getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers' + ? [{ Name: newOrderSelectionName }] + : '')) + } + }]; + + const wrapper = shallowMount(duplicateCheck, mountOptions); + wrapper.setData({ selectedAnswer: newOrderSelectionName }); + useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({})); + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.mainStore.loadSession).toHaveBeenCalledTimes(0); + expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); + }); + test('Load session throws error => still navigate forward', async () => { + // Arrange + const newOrderSelectionName = getRandomString(6, 6); + const selectedAnswer = getRandomString(6, 6); + + const mountOptions = getMountOptions({ + router: { navigate: jest.fn() } + }); + mountOptions.mixins = [{ + methods: { + getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers' + ? [{ Name: newOrderSelectionName }] + : '')) + } + }]; + + const wrapper = shallowMount(duplicateCheck, mountOptions); + wrapper.setData({ selectedAnswer }); + const error = 'load session error'; + useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.reject(error)); + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.mainStore.loadSession).toHaveBeenCalledTimes(1); + expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); + }); + test('policyLookupSuccessful true and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => { // Arrange const mountOptions = getMountOptions({ router: { navigate: jest.fn() } @@ -358,7 +438,7 @@ describe('duplicateCheck.vue', () => { order: { policy: { policyLookupSuccessful: true, - vehicles: [{test: 'a'}] + vehicles: [{ test: 'a' }] } } }; @@ -371,19 +451,19 @@ describe('duplicateCheck.vue', () => { const wrapper = shallowMount(duplicateCheck, mountOptions); // Act - wrapper.vm.forwardButtonAction(); + await wrapper.vm.forwardButtonAction(); // Assert expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigate) .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES, undefined); }); - test('policyLookupSuccessful true and no policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES', () => { + test('policyLookupSuccessful true and no policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES', async () => { // Arrange const mountOptions = getMountOptions({ router: { navigate: jest.fn() } }); - + const mainInitialState = { order: { policy: { @@ -401,19 +481,19 @@ describe('duplicateCheck.vue', () => { const wrapper = shallowMount(duplicateCheck, mountOptions); // Act - wrapper.vm.forwardButtonAction(); + await wrapper.vm.forwardButtonAction(); // Assert expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigate) .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES, undefined); }); - test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', () => { + test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', async () => { // Arrange const mountOptions = getMountOptions({ router: { navigate: jest.fn() } }); - + const mainInitialState = { order: { policy: { @@ -430,7 +510,7 @@ describe('duplicateCheck.vue', () => { const wrapper = shallowMount(duplicateCheck, mountOptions); // Act - wrapper.vm.forwardButtonAction(); + await wrapper.vm.forwardButtonAction(); // Assert expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); @@ -439,4 +519,4 @@ describe('duplicateCheck.vue', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/src/layouts/duplicate-check/duplicate-check.vue b/src/layouts/duplicate-check/duplicate-check.vue index 67e61a11..222309ec 100644 --- a/src/layouts/duplicate-check/duplicate-check.vue +++ b/src/layouts/duplicate-check/duplicate-check.vue @@ -42,6 +42,7 @@