Final touches
This commit is contained in:
parent
9efd351d9d
commit
3f6c8dbf93
5 changed files with 442 additions and 272 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
// Components
|
// Components
|
||||||
|
import { shallowMount } from '@vue/test-utils';
|
||||||
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
import contactDetails from '@/layouts/contact-details/contact-details.vue';
|
import contactDetails from '@/layouts/contact-details/contact-details.vue';
|
||||||
|
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
import { shallowMount } from '@vue/test-utils';
|
|
||||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import { getRandomString, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.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 navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
import { useMainStore } from '@/store/index.js';
|
import { useMainStore } from '@/store/index.js';
|
||||||
|
|
||||||
|
|
@ -267,10 +267,11 @@ describe('contactDetails.vue', () => {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn()
|
navigate: jest.fn()
|
||||||
},
|
|
||||||
global: {
|
|
||||||
plugins: [createTestingPinia()]
|
|
||||||
}
|
}
|
||||||
|
// ,
|
||||||
|
// global: {
|
||||||
|
// plugins: [createTestingPinia()]
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
const wrapper = shallowMount(contactDetails, mountOptions);
|
const wrapper = shallowMount(contactDetails, mountOptions);
|
||||||
const firstName = getRandomString(4, 15);
|
const firstName = getRandomString(4, 15);
|
||||||
|
|
@ -302,4 +303,81 @@ 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
// Components
|
// Components
|
||||||
|
import { shallowMount } from '@vue/test-utils';
|
||||||
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
import duplicateCheck from '@/layouts/duplicate-check/duplicate-check.vue';
|
import duplicateCheck from '@/layouts/duplicate-check/duplicate-check.vue';
|
||||||
|
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
import { shallowMount } from '@vue/test-utils';
|
|
||||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import { createTestingPinia } from '@pinia/testing';
|
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
import { getRandomString } from '@/helpers/data-generation.js';
|
import { getRandomString } from '@/helpers/data-generation.js';
|
||||||
|
import { useMainStore } from '@/store';
|
||||||
|
|
||||||
const duplicateOrderText = 'Finish Existing Claim';
|
const duplicateOrderText = 'Finish Existing Claim';
|
||||||
|
|
||||||
|
|
@ -52,279 +53,277 @@ describe('duplicateCheck.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(footer.exists()).toBeTruthy();
|
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', () => {
|
describe('computed properties', () => {
|
||||||
test('duplicateOrders in store undefined => returns empty list', () => {
|
describe('duplicateOrders computed', () => {
|
||||||
// Arrange
|
test('duplicateOrders in store undefined => returns empty list', () => {
|
||||||
const mountOptions = getMountOptions({
|
// Arrange
|
||||||
router: { navigate: jest.fn() }
|
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 = {
|
const mainInitialState = {
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: undefined
|
duplicateOrders: []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
mountOptions.global.plugins = [createTestingPinia({
|
||||||
initialState: {
|
initialState: {
|
||||||
main: mainInitialState
|
main: mainInitialState
|
||||||
}
|
}
|
||||||
})];
|
})];
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
||||||
});
|
|
||||||
test('duplicateOrders in store empty => returns empty list', () => {
|
|
||||||
// Arrange
|
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
});
|
||||||
|
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 = {
|
const referralNumber = getRandomString(6, 6);
|
||||||
applicationUser: {
|
const mainInitialState = {
|
||||||
duplicateOrders: []
|
applicationUser: {
|
||||||
}
|
duplicateOrders: [
|
||||||
};
|
{
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
vehicleYear: null,
|
||||||
initialState: {
|
vehicleMake: getRandomString(5, 5),
|
||||||
main: mainInitialState
|
vehicleModel: getRandomString(5, 5),
|
||||||
}
|
responseDate: '09/23/1990T01:12:34',
|
||||||
})];
|
referralNumber
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global.plugins = [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})];
|
||||||
|
const expectedSubtext = '09/23/1990';
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
});
|
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||||
test('duplicateOrder in store with null vehicle year => returns order with only date in subtext', () => {
|
Text: duplicateOrderText,
|
||||||
// Arrange
|
Name: referralNumber,
|
||||||
const mountOptions = getMountOptions({
|
SubText: expectedSubtext
|
||||||
router: { navigate: jest.fn() }
|
});
|
||||||
});
|
});
|
||||||
|
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 referralNumber = getRandomString(6, 6);
|
const mainInitialState = {
|
||||||
const mainInitialState = {
|
applicationUser: {
|
||||||
applicationUser: {
|
duplicateOrders: [
|
||||||
duplicateOrders: [
|
{
|
||||||
{
|
vehicleYear: getRandomString(6, 6),
|
||||||
vehicleYear: null,
|
vehicleMake: null,
|
||||||
vehicleMake: getRandomString(5, 5),
|
vehicleModel: getRandomString(5, 5),
|
||||||
vehicleModel: getRandomString(5, 5),
|
responseDate: '11/01/2004T01:12:34',
|
||||||
dateOfLoss: date,
|
referralNumber
|
||||||
referralNumber
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
}
|
};
|
||||||
};
|
mountOptions.global.plugins = [createTestingPinia({
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
initialState: {
|
||||||
initialState: {
|
main: mainInitialState
|
||||||
main: mainInitialState
|
}
|
||||||
}
|
})];
|
||||||
})];
|
const expectedSubtext = '11/01/2004';
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: date
|
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: '02/30/1999T01:12:34',
|
||||||
|
referralNumber
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global.plugins = [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})];
|
||||||
|
const expectedSubtext = '02/30/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: '03/01/2018T01:12:34',
|
||||||
|
referralNumber
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global.plugins = [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})];
|
||||||
|
const expectedVehicle = 'Year Make Model';
|
||||||
|
const expectedDate = '03/01/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', () => {
|
describe('getNewOrderSelectionName', () => {
|
||||||
// Arrange
|
test('answersFromCms null => returns empty string', () => {
|
||||||
const mountOptions = getMountOptions({
|
// Arrange
|
||||||
router: { navigate: jest.fn() }
|
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 wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
const referralNumber = getRandomString(6, 6);
|
|
||||||
const mainInitialState = {
|
|
||||||
applicationUser: {
|
|
||||||
duplicateOrders: [
|
|
||||||
{
|
|
||||||
vehicleYear: getRandomString(6, 6),
|
|
||||||
vehicleMake: null,
|
|
||||||
vehicleModel: getRandomString(5, 5),
|
|
||||||
dateOfLoss: date,
|
|
||||||
referralNumber
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
// Assert
|
||||||
|
expect(wrapper.vm.getNewOrderSelectionName).toBe('');
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
|
||||||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
|
||||||
Text: duplicateOrderText,
|
|
||||||
Name: referralNumber,
|
|
||||||
SubText: date
|
|
||||||
});
|
});
|
||||||
});
|
test('answersFromCms non-empty list whose first item has no Name property => returns empty string', () => {
|
||||||
test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => {
|
// Arrange
|
||||||
// Arrange
|
const mountOptions = getMountOptions({
|
||||||
const mountOptions = getMountOptions({
|
router: { navigate: jest.fn() }
|
||||||
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 wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
const referralNumber = getRandomString(6, 6);
|
|
||||||
const mainInitialState = {
|
|
||||||
applicationUser: {
|
|
||||||
duplicateOrders: [
|
|
||||||
{
|
|
||||||
vehicleYear: getRandomString(6, 6),
|
|
||||||
vehicleMake: getRandomString(6, 6),
|
|
||||||
vehicleModel: null,
|
|
||||||
dateOfLoss: date,
|
|
||||||
referralNumber
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
// Assert
|
||||||
|
expect(wrapper.vm.getNewOrderSelectionName).toBe(expectedName);
|
||||||
// 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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
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}`
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -348,7 +347,88 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('forwardButtonAction', () => {
|
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
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: { navigate: jest.fn() }
|
router: { navigate: jest.fn() }
|
||||||
|
|
@ -371,14 +451,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES, undefined);
|
.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
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: { navigate: jest.fn() }
|
router: { navigate: jest.fn() }
|
||||||
|
|
@ -401,14 +481,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES, undefined);
|
.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
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: { navigate: jest.fn() }
|
router: { navigate: jest.fn() }
|
||||||
|
|
@ -430,7 +510,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
||||||
|
|
@ -439,4 +519,4 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,10 @@ export default {
|
||||||
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
||||||
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const subtext = vehicle && o.responseDate
|
const subtext = vehicle && o.responseDate
|
||||||
? `${vehicle}, ${this.getDateMinusTime(o.responseDate)}`
|
? `${vehicle}, ${this.getDateMinusTime(o.responseDate)}`
|
||||||
: (vehicle ?? '').concat(this.getDateMinusTime(o.responseDate) ?? '');
|
: (vehicle ?? '').concat(this.getDateMinusTime(o.responseDate ?? ''));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
|
|
@ -131,9 +132,8 @@ export default {
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
if (this.selectedAnswer !== this.getNewOrderSelectionName) {
|
if (this.selectedAnswer !== this.getNewOrderSelectionName) {
|
||||||
await useMainStore().loadSession()
|
await useMainStore().loadSession()
|
||||||
.finally(() => {
|
.then(() => {}, () => {})
|
||||||
this.navigateForward();
|
.finally(() => { this.navigateForward(); });
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.navigateForward();
|
this.navigateForward();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
|
import { shallowMount } from '@vue/test-utils';
|
||||||
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
import welcomePage from '@/layouts/welcome-page/welcome-page.vue';
|
import welcomePage from '@/layouts/welcome-page/welcome-page.vue';
|
||||||
|
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { shallowMount } from '@vue/test-utils';
|
|
||||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
import baseMixin from '@/mixins/base-mixin.js';
|
import baseMixin from '@/mixins/base-mixin.js';
|
||||||
|
|
@ -10,8 +11,6 @@ import applicationConfig from '@/constants/application-config';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
||||||
import routerParams from '@/router/router-constants/router-params';
|
import routerParams from '@/router/router-constants/router-params';
|
||||||
import { getRandomString } from '@/helpers/data-generation.js';
|
|
||||||
import { createTestingPinia } from '@pinia/testing';
|
|
||||||
|
|
||||||
// Mock our module for promises.
|
// Mock our module for promises.
|
||||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||||
|
|
@ -294,7 +293,7 @@ describe('navigation', () => {
|
||||||
useMainStore().applicationUser.duplicateOrders = [];
|
useMainStore().applicationUser.duplicateOrders = [];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.navigateForward();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||||
|
|
@ -304,4 +303,16 @@ describe('navigation', () => {
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
test('getDuplicateReferrals throws rejected promise => navigate called', async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
const error = 'duplicate referrals error';
|
||||||
|
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.reject(error));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,7 @@ export default {
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
this.mainStore.updatePolicyData(this.welcomePageModel);
|
this.mainStore.updatePolicyData(this.welcomePageModel);
|
||||||
await this.mainStore.getDuplicateReferrals()
|
await this.mainStore.getDuplicateReferrals()
|
||||||
|
.then(() => {}, () => {})
|
||||||
.finally(async () => {
|
.finally(async () => {
|
||||||
if (this.isCoverageEnabled) {
|
if (this.isCoverageEnabled) {
|
||||||
await this.mainStore.getCoveragePolicyInfo();
|
await this.mainStore.getCoveragePolicyInfo();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue