Add to dup check test
This commit is contained in:
parent
44e429a66d
commit
cf15cb8b59
2 changed files with 58 additions and 4 deletions
|
|
@ -10,6 +10,8 @@ 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());
|
||||||
|
|
@ -89,6 +91,40 @@ function setupMocks({
|
||||||
return { wrapper, apiPromise };
|
return { wrapper, apiPromise };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMountedComponent(mainInitialState = {}, initialData = {}) {
|
||||||
|
const mountOptions = getMountOptions({
|
||||||
|
router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mountOptions.global.stubs = {
|
||||||
|
siteHeader: true,
|
||||||
|
recalModal: true,
|
||||||
|
contentGroupModal: true,
|
||||||
|
alert: true
|
||||||
|
};
|
||||||
|
mountOptions.global.plugins = [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})];
|
||||||
|
//mountOptions.mixins = [mockMixin];
|
||||||
|
mountOptions.data = () => (
|
||||||
|
initialData
|
||||||
|
);
|
||||||
|
|
||||||
|
const apiResponses = {
|
||||||
|
supportingItems: []
|
||||||
|
};
|
||||||
|
const apiPromise = Promise.resolve(apiResponses);
|
||||||
|
settleAllPromises.mockImplementation(() => apiPromise);
|
||||||
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
|
const wrapper = shallowMount(welcomePage, mountOptions);
|
||||||
|
return { wrapper };
|
||||||
|
}
|
||||||
|
|
||||||
describe('welcome-page.vue', () => {
|
describe('welcome-page.vue', () => {
|
||||||
test('Should render welcomePage sub-components (policyNumber, policyZipCode, dateOfLoss, damageCause etc.)', async () => {
|
test('Should render welcomePage sub-components (policyNumber, policyZipCode, dateOfLoss, damageCause etc.)', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -143,11 +179,24 @@ describe('welcome-page.vue', () => {
|
||||||
describe('navigation', () => {
|
describe('navigation', () => {
|
||||||
test('if duplicates found, navigate to duplicate check page', async () => {
|
test('if duplicates found, navigate to duplicate check page', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const accountNumber = getRandomString(5, 5);
|
||||||
|
const policyNumber = getRandomString(5, 5);
|
||||||
|
const dateOfLoss = getRandomString(5, 5);
|
||||||
|
const { wrapper } = getMountedComponent({
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
policyNumber: policyNumber,
|
||||||
|
dateOfLoss: dateOfLoss
|
||||||
|
}
|
||||||
|
},
|
||||||
|
issConfig: {
|
||||||
|
accountNumber: accountNumber
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const duplicatesExist = {
|
const duplicatesExist = {
|
||||||
policyLookupResponse: {},
|
policyLookupResponse: {},
|
||||||
duplicateCheckResponse: [{ test2: 'b'}]
|
duplicateCheckResponse: [{ test: 'a'}]
|
||||||
};
|
};
|
||||||
|
|
||||||
settleAllPromises.mockImplementation(() => Promise.resolve(duplicatesExist));
|
settleAllPromises.mockImplementation(() => Promise.resolve(duplicatesExist));
|
||||||
|
|
@ -156,6 +205,12 @@ describe('navigation', () => {
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
expect(wrapper.vm.mainStore.getDuplicates).toHaveBeenCalledWith(
|
||||||
|
{
|
||||||
|
accountNumber: accountNumber,
|
||||||
|
policyNumber: policyNumber,
|
||||||
|
dateOfLoss: dateOfLoss
|
||||||
|
});
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_DUPLICATES,
|
navigationScenarios.CLICKED_FORWARD_WITH_DUPLICATES,
|
||||||
undefined,
|
undefined,
|
||||||
|
|
|
||||||
|
|
@ -298,9 +298,8 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
this.mainStore.updatePolicyData(this.welcomePageModel);
|
this.mainStore.updatePolicyData(this.welcomePageModel);
|
||||||
|
|
||||||
const duplicateCheckResponse = useMainStore().getDuplicates({
|
const duplicateCheckResponse = useMainStore().getDuplicates({
|
||||||
accountNumber: this.mainStore.order.accountNumber.toString(),
|
accountNumber: this.mainStore.issConfig.accountNumber.toString(),
|
||||||
policyNumber: this.mainStore.order.policy.policyNumber,
|
policyNumber: this.mainStore.order.policy.policyNumber,
|
||||||
dateOfLoss: this.mainStore.order.policy.dateOfLoss
|
dateOfLoss: this.mainStore.order.policy.dateOfLoss
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue