SSR-1167 Only call getFinalDeductible for ITAC / Deductible cases.
Updated failing unit tests
This commit is contained in:
parent
072ff84451
commit
97a26159d3
5 changed files with 128 additions and 97 deletions
|
|
@ -391,23 +391,20 @@ describe('coverageStatement.vue', () => {
|
|||
});
|
||||
});
|
||||
describe.each([
|
||||
[false, false, false, true, true, 0],
|
||||
[false, true, true, true, true, 0],
|
||||
[false, true, false, false, true, 0],
|
||||
[false, true, false, true, false, 0],
|
||||
[false, true, false, true, true, -1],
|
||||
[false, true, false, true, true, null],
|
||||
[true, true, false, true, true, 0]
|
||||
[false, false, true, true, 0],
|
||||
[false, true, false, true, 0],
|
||||
[false, true, true, false, 0],
|
||||
[false, true, true, true, -1],
|
||||
[false, true, true, true, null],
|
||||
[true, true, true, true, 0]
|
||||
])('shouldRegisterClaim', (
|
||||
expected,
|
||||
isClaimRegistrationRequired,
|
||||
isClaimAlreadyRegistered,
|
||||
isPolicyLookupSuccessful,
|
||||
isPendingClaimRegistration,
|
||||
policyVehicleId
|
||||
) => {
|
||||
test(`returns ${expected} when isClaimRegistrationRequired is ${isClaimRegistrationRequired} `
|
||||
+ `and isClaimAlreadyRegistered is ${isClaimAlreadyRegistered} `
|
||||
+ `and isPolicyLookupSuccessful is ${isPolicyLookupSuccessful} `
|
||||
+ `and isPendingClaimRegistration is ${isPendingClaimRegistration} `
|
||||
+ `and policyVehicleId is ${(policyVehicleId == null ? 'NULL' : policyVehicleId)}`, () => {
|
||||
|
|
@ -416,8 +413,7 @@ describe('coverageStatement.vue', () => {
|
|||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: isPendingClaimRegistration ? coverageStatuses.PENDING : coverageStatuses.VERIFIED,
|
||||
coverageType: isPolicyLookupSuccessful ? coverageType.Deductible : coverageType.NONE,
|
||||
claimNumber: isClaimAlreadyRegistered ? getRandomString(6, 6) : null
|
||||
coverageType: isPolicyLookupSuccessful ? coverageType.Deductible : coverageType.NONE
|
||||
},
|
||||
vehicle: {
|
||||
policyVehicleId
|
||||
|
|
|
|||
|
|
@ -173,9 +173,12 @@ export default {
|
|||
|
||||
let hasBailedOut = false;
|
||||
let pricingResults = [];
|
||||
const { vehicle, isPolicyLookupSuccessful } = useMainStore();
|
||||
const { vehicle, isPolicyLookupSuccessful, isITAC, isDeductible } = useMainStore();
|
||||
if (isPolicyLookupSuccessful && vehicle.policyVehicleId >= 0) {
|
||||
await useMainStore().getFinalDeductible();
|
||||
if (isITAC || isDeductible) {
|
||||
await useMainStore().getFinalDeductible();
|
||||
}
|
||||
|
||||
pricingResults = await useMainStore()
|
||||
.getPriceOrderItems(availableLineItems)
|
||||
.catch((err) => {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { useMainStore } from '@/store';
|
|||
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
||||
import routerParams from '@/router/router-constants/router-params';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
import globalMethods from '@/global-methods';
|
||||
|
||||
// Mock our module for promises.
|
||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||
|
|
@ -20,6 +21,9 @@ jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
|||
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||
fetchCmsContentForPage: jest.fn()
|
||||
}));
|
||||
jest.mock('@/global-methods', () => ({
|
||||
callHttpClient: jest.fn()
|
||||
}));
|
||||
|
||||
/** @ignore */
|
||||
function setupMocks({
|
||||
|
|
@ -168,13 +172,9 @@ describe('navigation', () => {
|
|||
test('Navigation should not happen', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: false
|
||||
}
|
||||
}));
|
||||
wrapper.vm.mainStore.getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
wrapper.vm.mainStore.applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.reject());
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
|
@ -209,78 +209,6 @@ describe('navigation', () => {
|
|||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||
);
|
||||
});
|
||||
test('if isCoverageEnabled is false, then getCoveragePolicyInfo not called', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().issConfig.isCoverageEnabled = false;
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: true
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).not.toHaveBeenCalled();
|
||||
});
|
||||
test('if isCoverageEnabled is true, then getCoveragePolicyInfo called', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().issConfig.isCoverageEnabled = true;
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: true
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalled();
|
||||
});
|
||||
test('if maxCoverageLookupAttemptsReached is true, then getCoveragePolicyInfo not called', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().applicationUser.coverageLookupAttempts = 11;
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: true
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).not.toHaveBeenCalled();
|
||||
});
|
||||
test('if maxCoverageLookupAttemptsReached is false, then getCoveragePolicyInfo called', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().applicationUser.coverageLookupAttempts = 10;
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: true
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalled();
|
||||
});
|
||||
test('if policy and vehicles are found but no duplicates, navigate to policy-vehicle page', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ export const useMainStore = defineStore({
|
|||
const { order, issConfig, applicationUser } = this;
|
||||
const { policy } = order;
|
||||
|
||||
if (issConfig.isCoverageEnabled && applicationUser.coverageLookupAttempts > 10) {
|
||||
if (!issConfig.isCoverageEnabled || applicationUser.coverageLookupAttempts > 10) {
|
||||
this.updateCoverageType(coverageType.NONE);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1228,6 +1228,8 @@ describe('Store', () => {
|
|||
describe('successful method call', () => {
|
||||
it('calls getCoveragePolicyInfo api endpoint', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
|
|
@ -1239,16 +1241,55 @@ describe('Store', () => {
|
|||
endpoint: endpoints.CoveragePolicyInfo.url
|
||||
}));
|
||||
});
|
||||
it('Returns expected response object', async () => {
|
||||
it('Sets policy fields for successful policy lookup', async () => {
|
||||
// Arrange
|
||||
const response = { ReferralNumber: getRandomString(6, 6) };
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
|
||||
const address = getRandomString(6, 6);
|
||||
const city = getRandomString(6, 6);
|
||||
const state = getRandomString(6, 6);
|
||||
const zipCode = getRandomString(6, 6);
|
||||
const firstName = getRandomString(6, 6);
|
||||
const lastName = getRandomString(6, 6);
|
||||
|
||||
const vehicle = { id: '123' };
|
||||
|
||||
const response = {
|
||||
data: {
|
||||
policies: [
|
||||
{
|
||||
insureds: [
|
||||
{
|
||||
address,
|
||||
city,
|
||||
state,
|
||||
zipCode,
|
||||
firstName,
|
||||
lastName
|
||||
}
|
||||
],
|
||||
vehicles: [
|
||||
vehicle
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
// Act
|
||||
const result = store.getCoveragePolicyInfo();
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Asserts
|
||||
await expect(result).resolves.toBe(response);
|
||||
await expect(store.order.customer.address.streetAddress).toBe(address);
|
||||
await expect(store.order.customer.address.city).toBe(city);
|
||||
await expect(store.order.customer.address.state).toBe(state);
|
||||
await expect(store.order.customer.address.zipCode).toBe(zipCode);
|
||||
await expect(store.order.customer.firstName).toBe(firstName);
|
||||
await expect(store.order.customer.lastName).toBe(lastName);
|
||||
await expect(store.order.serviceLocation.zipCode).toBe(zipCode);
|
||||
await expect(store.order.policy.vehicles).toStrictEqual([vehicle])
|
||||
});
|
||||
it('calls api with expected data', async () => {
|
||||
// Arrange
|
||||
|
|
@ -1262,6 +1303,8 @@ describe('Store', () => {
|
|||
store.order.policy.dateOfLoss = dateOfLoss;
|
||||
store.order.policy.policyZipCode = zipCode;
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
|
|
@ -1280,6 +1323,8 @@ describe('Store', () => {
|
|||
});
|
||||
it('null response by api => insuranceCoverage.coverageType is NONE', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(null));
|
||||
|
||||
// Act
|
||||
|
|
@ -1290,6 +1335,8 @@ describe('Store', () => {
|
|||
});
|
||||
it('no policies returned by api => insuranceCoverage.coverageType is NONE', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
const responseNoPolicies = {
|
||||
data: {
|
||||
policies: []
|
||||
|
|
@ -1326,6 +1373,8 @@ describe('Store', () => {
|
|||
policies: [policy1, {}]
|
||||
}
|
||||
};
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(responseNoPolicies));
|
||||
|
||||
// Act
|
||||
|
|
@ -1361,6 +1410,8 @@ describe('Store', () => {
|
|||
}]
|
||||
}
|
||||
};
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(responseNoPolicies));
|
||||
|
||||
// Act
|
||||
|
|
@ -1377,6 +1428,8 @@ describe('Store', () => {
|
|||
policies: [{ vehicles: [] }]
|
||||
}
|
||||
};
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(responseNoPolicies));
|
||||
|
||||
// Act
|
||||
|
|
@ -1387,9 +1440,57 @@ describe('Store', () => {
|
|||
expect(store.order.policy.vehicles).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
test('if isCoverageEnabled is false, then getCoveragePolicyInfo not called', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = false;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).not.toHaveBeenCalled();
|
||||
});
|
||||
test('if isCoverageEnabled is true, then getCoveragePolicyInfo called', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||
});
|
||||
test('if maxCoverageLookupAttemptsReached is true, then getCoveragePolicyInfo not called', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 11;
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).not.toHaveBeenCalled();
|
||||
});
|
||||
test('if maxCoverageLookupAttemptsReached is false, then getCoveragePolicyInfo called', async () => {
|
||||
// Arrange
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 10;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve());
|
||||
|
||||
// Act
|
||||
await store.getCoveragePolicyInfo();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||
});
|
||||
it('api call throws exception => insuranceCoverage.coverageType is NONE', async () => {
|
||||
expect.assertions(3);
|
||||
const error = 'get coverage policy info error';
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||
|
||||
// Act
|
||||
|
|
@ -1938,6 +2039,9 @@ describe('Store', () => {
|
|||
it('api call throws exception => coverageType none', async () => {
|
||||
expect.assertions(3);
|
||||
const error = 'get coverage policy info error';
|
||||
|
||||
store.issConfig.isCoverageEnabled = true;
|
||||
store.applicationUser.coverageLookupAttempts = 0;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||
|
||||
// Act
|
||||
|
|
|
|||
Loading…
Reference in a new issue