Finishing coverage statement tests
This commit is contained in:
parent
7757bc6cfd
commit
320093cf2d
3 changed files with 767 additions and 30 deletions
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`coverageStatement.vue-working returns the initial data 1`] = `
|
||||||
|
Object {
|
||||||
|
"baseServiceLineItems": Array [],
|
||||||
|
"currencyFormatter": NumberFormat {},
|
||||||
|
"deductibleText": "Your deductible is",
|
||||||
|
"isNoComp": false,
|
||||||
|
"isRepair": true,
|
||||||
|
"loadingText": Array [
|
||||||
|
"Connecting to your insurance company",
|
||||||
|
"Nearly there",
|
||||||
|
"Finishing up",
|
||||||
|
],
|
||||||
|
"policyLookupSuccessful": true,
|
||||||
|
"rules": Object {
|
||||||
|
"selectionRequired": "option-required",
|
||||||
|
},
|
||||||
|
"selectedProvider": "",
|
||||||
|
"supportingItems": null,
|
||||||
|
"widget": Object {
|
||||||
|
"explanatoryText": "ExplanatoryTextWidget",
|
||||||
|
"nextStep": "NextStepsWidget",
|
||||||
|
"serviceProviderQuestion": "ServiceProviderQuestion",
|
||||||
|
"subheader": "SiteSubHeaderWidget",
|
||||||
|
"verifiedItacAlert": "VerifiedITACAlert",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
@ -3,7 +3,7 @@ import coverageStatement from '@/layouts/coverage-statement/coverage-statement.v
|
||||||
|
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
import { mount } from '@vue/test-utils';
|
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 { createTestingPinia } from '@pinia/testing';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
|
|
@ -12,8 +12,10 @@ import settleAllPromises from '@/helpers/layout-helper.js';
|
||||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
import routerParams from '@/router/router-constants/router-params';
|
import routerParams from '@/router/router-constants/router-params';
|
||||||
import { useMainStore } from '@/store/index.js';
|
import { useMainStore } from '@/store/index.js';
|
||||||
|
import getPriceOfLineItems from '@/helpers/price-calculator.js';
|
||||||
|
|
||||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||||
|
jest.mock('@/helpers/price-calculator.js', () => jest.fn());
|
||||||
|
|
||||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
fetchCmsContentForPage: jest.fn(),
|
fetchCmsContentForPage: jest.fn(),
|
||||||
|
|
@ -24,7 +26,10 @@ jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
const mockMixin = {
|
const mockMixin = {
|
||||||
methods: {
|
methods: {
|
||||||
getCmsContent: jest.fn().mockImplementation(() => ''),
|
getCmsContent: jest.fn().mockImplementation(() => ''),
|
||||||
setCmsContent: jest.fn()
|
setCmsContent: jest.fn(),
|
||||||
|
onSubmit: jest.fn(),
|
||||||
|
onInvalidSubmit: jest.fn(),
|
||||||
|
navigateBackByVehicleQuestions: jest.fn()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -51,6 +56,7 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
|
||||||
});
|
});
|
||||||
|
|
||||||
mountOptions.global.stubs = {
|
mountOptions.global.stubs = {
|
||||||
|
...mountOptions.global.stubs,
|
||||||
siteFooter: footerStub,
|
siteFooter: footerStub,
|
||||||
siteHeader: true,
|
siteHeader: true,
|
||||||
recalModal: true,
|
recalModal: true,
|
||||||
|
|
@ -79,7 +85,7 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
|
||||||
settleAllPromises.mockImplementation(() => apiPromise);
|
settleAllPromises.mockImplementation(() => apiPromise);
|
||||||
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
const wrapper = mount(coverageStatement, mountOptions);
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
return { wrapper };
|
return { wrapper };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -775,7 +781,24 @@ describe.skip('coverageStatement.vue', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('coverageStatement.vue-working', () => {
|
describe('coverageStatement.vue-working', () => {
|
||||||
// test('initial data is as expected', () => {});
|
test('returns the initial data', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: true,
|
||||||
|
noCoverage: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$data).toMatchSnapshot();
|
||||||
|
});
|
||||||
describe('Rendering', () => {
|
describe('Rendering', () => {
|
||||||
test('Should render site header', () => {
|
test('Should render site header', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -830,39 +853,724 @@ describe('coverageStatement.vue-working', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Computed', () => {
|
describe('Computed', () => {
|
||||||
describe.only('verifiedNoComp', () => {
|
describe('verifiedNoComp', () => {
|
||||||
test.each([true, false])('returns false when policyLookupSuccessful false', (isNoComp) => {
|
test.each([true, false])('returns false when policyLookupSuccessful false', (isNoComp) => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: isNoComp,
|
||||||
|
policyLookupSuccessful: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedNoComp;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
});
|
});
|
||||||
test.each([true, false])('returns false when isNoComp false', (policyLookupSuccessful) => {});
|
test.each([true, false])('returns false when isNoComp false', (policyLookupSuccessful) => {
|
||||||
test('returns true when policyLookupSuccessful true and policyLookupSuccessful true', () => {
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
policyLookupSuccessful
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedNoComp;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns true when policyLookupSuccessful true and policyLookupSuccessful true', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedNoComp;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('verifiedITAC', () => {
|
describe('verifiedITAC', () => {
|
||||||
test('returns false when policyLookupSuccessful false', () => {});
|
const priceOfLineItems = 213;
|
||||||
test('returns false when isNoComp true', () => {});
|
test.each([true, false])('returns false when policyLookupSuccessful false', (isNoComp) => {
|
||||||
test('returns false when deductibleValue equals totalServicePrice', () => {});
|
// Arrange
|
||||||
test('returns false when deductibleValue less than totalServicePrice', () => {});
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: isNoComp,
|
||||||
|
policyLookupSuccessful: false
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems + 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedITAC;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test.each([true, false])('returns false when isNoComp true', (policyLookupSuccessful) => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
policyLookupSuccessful
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems + 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedITAC;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test.each([
|
||||||
|
[true, false],
|
||||||
|
[true, true],
|
||||||
|
[false, false],
|
||||||
|
[false, true]
|
||||||
|
])('returns false when deductibleValue equals totalServicePrice', (noCoverage, policyLookupSuccessful) => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage,
|
||||||
|
policyLookupSuccessful
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedITAC;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test.each([
|
||||||
|
[true, false],
|
||||||
|
[true, true],
|
||||||
|
[false, false],
|
||||||
|
[false, true]
|
||||||
|
])(
|
||||||
|
'returns false when deductibleValue less than totalServicePrice when noCoverage is %p and policyLookupSuccessful is %p',
|
||||||
|
(noCoverage, policyLookupSuccessful) => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage,
|
||||||
|
policyLookupSuccessful
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems - 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedITAC;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
test('returns true when deductibleValue more than totalServicePrice, noComp is false, and policyLookupSuccessful true', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems + 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedITAC;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('verifiedDeductible', () => {
|
describe('verifiedDeductible', () => {
|
||||||
test('', () => { });
|
const servicePrice = 123;
|
||||||
test('', () => { });
|
describe('claim registration required', () => {
|
||||||
test('', () => { });
|
const issConfig = { isClaimRegistrationRequired: true };
|
||||||
test('', () => { });
|
let verifiedDeductibleStoreState;
|
||||||
test('', () => { });
|
beforeEach(() => {
|
||||||
test('', () => { });
|
verifiedDeductibleStoreState = {
|
||||||
test('', () => { });
|
issConfig,
|
||||||
|
order: {
|
||||||
|
payment: {
|
||||||
|
insuranceCoverage: {
|
||||||
|
isVerified: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
policyLookupSuccessful: false
|
||||||
|
},
|
||||||
|
currentDeductible: servicePrice - 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementation(() => servicePrice);
|
||||||
|
});
|
||||||
|
test('returns false when deductible is null', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = verifiedDeductibleStoreState;
|
||||||
|
mainInitialState.order.currentDeductible = null;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedDeductible;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when register claim not successful', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = verifiedDeductibleStoreState;
|
||||||
|
mainInitialState.order.payment.insuranceCoverage.isVerified = false;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedDeductible;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns true when register claim successful, isNoComp false, and service price over deductible', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(verifiedDeductibleStoreState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedDeductible;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('claim registration not required', () => {
|
||||||
|
const issConfig = { isClaimRegistrationRequired: false };
|
||||||
|
let verifiedDeductibleStoreState;
|
||||||
|
beforeEach(() => {
|
||||||
|
verifiedDeductibleStoreState = {
|
||||||
|
issConfig,
|
||||||
|
order: {
|
||||||
|
payment: {
|
||||||
|
insuranceCoverage: {
|
||||||
|
isVerified: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
},
|
||||||
|
currentDeductible: servicePrice - 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
test('returns false when policy lookup not successful', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = verifiedDeductibleStoreState;
|
||||||
|
mainInitialState.order.policy.policyLookupSuccessful = false;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedDeductible;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns true when policyLookupSuccessful, isNoComp false, and deductible over service price', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(verifiedDeductibleStoreState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedDeductible;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('returns false when isNoComp true', () => {
|
||||||
|
// Arrange
|
||||||
|
const isNoComp = true;
|
||||||
|
const storeState = {
|
||||||
|
issConfig: {
|
||||||
|
isClaimRegistrationRequired: false
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
payment: {
|
||||||
|
insuranceCoverage: {
|
||||||
|
isVerified: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: isNoComp,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
},
|
||||||
|
currentDeductible: servicePrice - 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedDeductible;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when service price below deductible', () => {
|
||||||
|
// Arrange
|
||||||
|
const storeState = {
|
||||||
|
issConfig: {
|
||||||
|
isClaimRegistrationRequired: false
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
payment: {
|
||||||
|
insuranceCoverage: {
|
||||||
|
isVerified: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
},
|
||||||
|
currentDeductible: servicePrice + 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.verifiedDeductible;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('isADAS', () => {
|
||||||
|
test('returns false when glassParts null', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
glassParts: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isADAS;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when glassParts empty', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
glassParts: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isADAS;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when no parts in glassParts require recalibration', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
glassParts: [
|
||||||
|
{
|
||||||
|
partNumber: 123,
|
||||||
|
requiresRecalibration: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
partNumber: 111,
|
||||||
|
requiresRecalibration: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isADAS;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns true when a part in glassParts require recalibration', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
glassParts: [
|
||||||
|
{
|
||||||
|
partNumber: 123,
|
||||||
|
requiresRecalibration: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
partNumber: 111,
|
||||||
|
requiresRecalibration: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isADAS;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('isQuoteDisplayed', () => {
|
||||||
|
test('returns false when policy lookup not successful', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isQuoteDisplayed;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
describe('not no comp', () => {
|
||||||
|
const priceOfLineItems = 341;
|
||||||
|
test('returns false when deductible equal to service price', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: true,
|
||||||
|
noCoverage: false
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isQuoteDisplayed;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when deductible less than service price', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: true,
|
||||||
|
noCoverage: false
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems - 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isQuoteDisplayed;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns true when policy lookup successful and deductible over service price', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: true,
|
||||||
|
noCoverage: false
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems + 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isQuoteDisplayed;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('not itac', () => {
|
||||||
|
const priceOfLineItems = 23;
|
||||||
|
test('returns false when isNoComp false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: true,
|
||||||
|
noCoverage: false
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isQuoteDisplayed;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns true when isNoComp true', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: true,
|
||||||
|
noCoverage: true
|
||||||
|
},
|
||||||
|
currentDeductible: priceOfLineItems
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementationOnce(() => priceOfLineItems);
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.isQuoteDisplayed;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe.each([[0], [12]])('shouldRegisterClaim', (policyVehicleId) => {
|
||||||
|
const servicePrice = 90;
|
||||||
|
let shouldRegisterClaimStoreStateItac;
|
||||||
|
beforeEach(() => {
|
||||||
|
shouldRegisterClaimStoreStateItac = {
|
||||||
|
order: {
|
||||||
|
payment: {
|
||||||
|
insuranceCoverage: { claimNumber: null }
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: true,
|
||||||
|
noCoverage: false
|
||||||
|
},
|
||||||
|
vehicle: {
|
||||||
|
policyVehicleId
|
||||||
|
},
|
||||||
|
currentDeductible: servicePrice - 1
|
||||||
|
},
|
||||||
|
issConfig: {
|
||||||
|
isClaimRegistrationRequired: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementation(() => servicePrice);
|
||||||
|
});
|
||||||
|
test('returns false when policy lookup not successful', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||||
|
mainInitialState.order.policy.policyLookupSuccessful = false;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.shouldRegisterClaim;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when policy vehicle id is less than 0', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||||
|
mainInitialState.order.vehicle.policyVehicleId = -3;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.shouldRegisterClaim;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when policy vehicle id is null', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||||
|
mainInitialState.order.vehicle.policyVehicleId = null;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.shouldRegisterClaim;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when claim registration is not required', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||||
|
mainInitialState.issConfig.isClaimRegistrationRequired = false;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.shouldRegisterClaim;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when claim already registered', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||||
|
mainInitialState.order.payment.insuranceCoverage.claimNumber = 13;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.shouldRegisterClaim;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false when no comp', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||||
|
mainInitialState.order.policy.noCoverage = true;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.shouldRegisterClaim;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
describe('returns true when policy lookup success, vehicleId set to %p, claim reg req, claim not yet reg', () => {
|
||||||
|
test('and itac', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(shouldRegisterClaimStoreStateItac);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.shouldRegisterClaim;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
|
test.each([
|
||||||
|
[servicePrice],
|
||||||
|
[servicePrice + 1]
|
||||||
|
])('and deductible case', (deductibleValue) => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = shouldRegisterClaimStoreStateItac;
|
||||||
|
mainInitialState.currentDeductible = deductibleValue;
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.shouldRegisterClaim;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('unverified', () => {});
|
|
||||||
describe('isADAS', () => {});
|
|
||||||
describe('itacCostSavings', () => {});
|
|
||||||
describe('isQuoteDisplayed', () => {});
|
|
||||||
describe('shouldRegisterClaim', () => {});
|
|
||||||
});
|
});
|
||||||
describe('methods', () => {
|
describe('methods', () => {
|
||||||
describe('arePagePrerequisitesValid', () => {
|
describe('arePagePrerequisitesValid', () => {
|
||||||
|
test('returns false if car id not set', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
vehicle: {
|
||||||
|
carId: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('returns false if car id set to 0', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
vehicle: {
|
||||||
|
carId: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
test.each([[-1], [1], [123]])('returns true if car id set to %p', (carId) => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
vehicle: { carId }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
test.each([
|
test.each([
|
||||||
[0, '$0.00'],
|
[0, '$0.00'],
|
||||||
|
|
@ -873,7 +1581,7 @@ describe('coverageStatement.vue-working', () => {
|
||||||
[1.254, '$1.25'],
|
[1.254, '$1.25'],
|
||||||
[1.255, '$1.26'],
|
[1.255, '$1.26'],
|
||||||
[-1, '-$1.00']
|
[-1, '-$1.00']
|
||||||
])('getFormattedAmount', (value, expected) => {
|
])('getFormattedAmount given %p returns "%p"', (value, expected) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getMountedComponent();
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
|
|
@ -883,9 +1591,6 @@ describe('coverageStatement.vue-working', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(expected);
|
expect(result).toBe(expected);
|
||||||
});
|
});
|
||||||
describe('navigateForward', () => {
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
describe('ITAC flag', () => {
|
describe('ITAC flag', () => {
|
||||||
test('ITAC flag updated once component is initialized', async () => {
|
test('ITAC flag updated once component is initialized', async () => {
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,6 @@ import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin.js';
|
||||||
import globalRules from '@/constants/global-rules.js';
|
import globalRules from '@/constants/global-rules.js';
|
||||||
import baseFormMixin from '@/mixins/base-form-mixin.js';
|
import baseFormMixin from '@/mixins/base-form-mixin.js';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
import routerParams from '@/router/router-constants/router-params';
|
|
||||||
import issPageValues from '@/router/router-constants/issPage-values';
|
import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
import bailoutMessage from '@/constants/bailoutMessage';
|
import bailoutMessage from '@/constants/bailoutMessage';
|
||||||
import widgetFields from '@/constants/cms-widget-fields.js';
|
import widgetFields from '@/constants/cms-widget-fields.js';
|
||||||
|
|
@ -311,8 +310,11 @@ export default {
|
||||||
},
|
},
|
||||||
verifiedDeductible() {
|
verifiedDeductible() {
|
||||||
return useMainStore().isClaimRegistrationRequired
|
return useMainStore().isClaimRegistrationRequired
|
||||||
? this.registerClaimSuccessful && this.coveredAndServicePriceAboveOrEqualDeductible && this.deductibleValue !== null
|
? this.registerClaimSuccessful
|
||||||
: this.policyLookupSuccessful && this.coveredAndServicePriceAboveOrEqualDeductible;
|
&& this.coveredAndServicePriceAboveOrEqualDeductible
|
||||||
|
&& this.deductibleValue !== null
|
||||||
|
: this.policyLookupSuccessful
|
||||||
|
&& this.coveredAndServicePriceAboveOrEqualDeductible;
|
||||||
},
|
},
|
||||||
unverified() {
|
unverified() {
|
||||||
return !this.verifiedDeductible && !this.verifiedITAC && !this.verifiedNoComp;
|
return !this.verifiedDeductible && !this.verifiedITAC && !this.verifiedNoComp;
|
||||||
|
|
@ -350,6 +352,7 @@ export default {
|
||||||
},
|
},
|
||||||
shouldRegisterClaim() {
|
shouldRegisterClaim() {
|
||||||
return this.policyLookupSuccessful
|
return this.policyLookupSuccessful
|
||||||
|
&& useMainStore().vehicle.policyVehicleId != null
|
||||||
&& useMainStore().vehicle.policyVehicleId >= 0
|
&& useMainStore().vehicle.policyVehicleId >= 0
|
||||||
&& useMainStore().isClaimRegistrationRequired
|
&& useMainStore().isClaimRegistrationRequired
|
||||||
&& !useMainStore().isClaimAlreadyRegistered
|
&& !useMainStore().isClaimAlreadyRegistered
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue