1219 lines
38 KiB
JavaScript
1219 lines
38 KiB
JavaScript
// Components
|
|
import coverageStatement from '@/layouts/coverage-statement/coverage-statement';
|
|
|
|
// Supporting Files
|
|
import { mount } 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 { useMainStore } from '@/store/index.js';
|
|
import { getRandomString, getRandomInt } from '@/helpers/data-generation.js';
|
|
import { settleAllPromises } from '@/helpers/layout-helper.js';
|
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
|
|
|
// Mock our module for promises
|
|
jest.mock('@/helpers/layout-helper.js', () => ({
|
|
settleAllPromises: jest.fn(),
|
|
}));
|
|
|
|
// Mock fetchCmsContentForPage, setupModalLinks, and processIfStatements
|
|
jest.mock('@/helpers/cms-content-helper', () => ({
|
|
fetchCmsContentForPage: jest.fn(),
|
|
setupModalLinks: jest.fn(),
|
|
processIfStatements: jest.fn()
|
|
}));
|
|
|
|
const mockMixin = {
|
|
methods: {
|
|
getCmsContent: jest.fn().mockImplementation(() => ''),
|
|
setCmsContent: jest.fn()
|
|
}
|
|
};
|
|
|
|
const footerStub = {
|
|
render: () => {},
|
|
methods: {
|
|
updateButtonText: jest.fn()
|
|
}
|
|
};
|
|
|
|
const loadingModalStub = {
|
|
render: () => {},
|
|
methods: {
|
|
showModal: jest.fn(),
|
|
hideModal: jest.fn()
|
|
}
|
|
};
|
|
|
|
function setupMocks() {
|
|
const mountOptions = getMountOptions({
|
|
router: {
|
|
navigate: jest.fn()
|
|
}
|
|
});
|
|
|
|
mountOptions.global = {
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
mountOptions.mixins = [mockMixin];
|
|
|
|
const apiResponses = {
|
|
supportingItems: []
|
|
};
|
|
const apiPromise = Promise.resolve(apiResponses);
|
|
settleAllPromises.mockImplementation(() => apiPromise);
|
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
|
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
|
|
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
|
return { wrapper };
|
|
}
|
|
|
|
describe('coverageStatement.vue', () => {
|
|
describe('method arePagePrerequisitesValid...', () => {
|
|
test('Should return true for valid page requisites if vin exists', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({});
|
|
useMainStore().order.vehicle.vin = getRandomString(5,20);
|
|
|
|
// Act
|
|
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
|
|
|
// Assert
|
|
expect(arePagePrerequisitesValid).toBe(true);
|
|
});
|
|
test('Should return false for valid page requisites if vin is missing', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({});
|
|
|
|
useMainStore().order.vehicle.vin = null;
|
|
|
|
// Act
|
|
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
|
|
|
// Assert
|
|
expect(arePagePrerequisitesValid).toBe(false);
|
|
});
|
|
});
|
|
describe('Rendering', () => {
|
|
test('Should render site header', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({});
|
|
|
|
// Act
|
|
const siteHeader = wrapper.findComponent({ ref: 'siteHeader' });
|
|
|
|
// Assert
|
|
expect(siteHeader.exists()).toBe(true);
|
|
});
|
|
test('Should render site subheader', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({});
|
|
|
|
// Act
|
|
const subheader = wrapper.find({ ref: 'siteSubHeader' });
|
|
|
|
// Assert
|
|
expect(subheader.exists()).toBe(true);
|
|
});
|
|
|
|
test('Should render explanatory text', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({});
|
|
|
|
// Act
|
|
const explanatoryText = wrapper.find({ ref: 'explanatoryText' });
|
|
|
|
// Assert
|
|
expect(explanatoryText.exists()).toBe(true);
|
|
});
|
|
test('Should render secondary text', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({});
|
|
|
|
// Act
|
|
const secondaryText = wrapper.find({ ref: 'secondaryText' });
|
|
|
|
// Assert
|
|
expect(secondaryText.exists()).toBe(true);
|
|
});
|
|
test('Should render site footer', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({});
|
|
|
|
// Act
|
|
const footer = wrapper.findComponent({ ref: 'siteFooter' });
|
|
|
|
// Assert
|
|
expect(footer.exists()).toBe(true);
|
|
});
|
|
});
|
|
describe('Verified ITAC scenario', () => {
|
|
test('If policy lookup successful, not No Comp, and deductible > service price, verifiedITAC returns true', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const sellingPrice = getRandomInt(100, 500);
|
|
const deductible = sellingPrice + 1;
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: false,
|
|
deductible: {
|
|
repair: deductible
|
|
},
|
|
policyLookupSuccessful: true
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.setData({
|
|
availableLineItems: [
|
|
{
|
|
sellingPrice,
|
|
kitPrice: 0,
|
|
laborAmount: 0
|
|
}
|
|
]
|
|
});
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedITAC).toBeTruthy();
|
|
});
|
|
test('If policy lookup unsuccessful, verifiedITAC returns false', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
policyLookupSuccessful: false
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedITAC).toBeFalsy();
|
|
});
|
|
test('If No Comp, verifiedITAC returns false', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: true
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedITAC).toBeFalsy();
|
|
});
|
|
test('If deductible < service price, verifiedITAC returns false', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const sellingPrice = getRandomInt(100, 500);
|
|
const deductible = sellingPrice - 1;
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: false,
|
|
deductible: {
|
|
repair: deductible
|
|
}
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.setData({
|
|
availableLineItems: [
|
|
{
|
|
sellingPrice,
|
|
kitPrice: 0,
|
|
laborAmount: 0
|
|
}
|
|
]
|
|
});
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedITAC).toBeFalsy();
|
|
});
|
|
});
|
|
describe('Verified Deductible scenario', () => {
|
|
test('If policy lookup successful, not No Comp, and service price > deductible, verifiedITAC returns true', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const sellingPrice = getRandomInt(100, 500);
|
|
const deductible = sellingPrice - 1;
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: false,
|
|
deductible: {
|
|
repair: deductible
|
|
},
|
|
policyLookupSuccessful: true
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.setData({
|
|
availableLineItems: [
|
|
{
|
|
sellingPrice,
|
|
kitPrice: 0,
|
|
laborAmount: 0
|
|
}
|
|
]
|
|
});
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedDeductible).toBeTruthy();
|
|
});
|
|
test('If policy lookup unsuccessful, verifiedDeductible returns false', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
policyLookupSuccessful: false
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
|
});
|
|
test('If No Comp, verifiedDeductible returns false', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: true
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
|
});
|
|
test('If service price < deductible, verifiedDeductible returns false', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const sellingPrice = getRandomInt(100, 500);
|
|
const deductible = sellingPrice + 1;
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: false,
|
|
deductible: {
|
|
repair: deductible
|
|
}
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.setData({
|
|
availableLineItems: [
|
|
{
|
|
sellingPrice,
|
|
kitPrice: 0,
|
|
laborAmount: 0
|
|
}
|
|
]
|
|
});
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
|
});
|
|
});
|
|
describe('No Comp scenario', () => {
|
|
test('If noCoverage = true, verifiedNoComp returns true', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: true,
|
|
policyLookupSuccessful: true
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedNoComp).toBeTruthy();
|
|
});
|
|
test('If noCoverage = false, verifiedNoComp returns false', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: false
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.verifiedNoComp).toBeFalsy();
|
|
});
|
|
});
|
|
describe('Unverified scenario', () => {
|
|
test('If policyLookupSuccessful false, unverified returns true', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
policyLookupSuccessful: false
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.unverified).toBeTruthy();
|
|
});
|
|
test('If policyLookupSuccessful is true, unverified returns false', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
policyLookupSuccessful: true
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.unverified).toBeFalsy();
|
|
});
|
|
});
|
|
describe('Navigation', () => {
|
|
test('If Unverified, navigate forward with CLICKED_FORWARD scenario', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
router: {
|
|
navigate: jest.fn()
|
|
},
|
|
mixins: [mockMixin]
|
|
};
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
policyLookupSuccessful: false
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
},
|
|
mocks: {
|
|
$router: {
|
|
navigate: jest.fn()
|
|
}
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Act
|
|
wrapper.vm.forwardButtonAction();
|
|
|
|
// Assert
|
|
expect(wrapper.vm.$router.navigate)
|
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD, undefined);
|
|
});
|
|
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
router: {
|
|
navigate: jest.fn()
|
|
},
|
|
mixins: [mockMixin]
|
|
};
|
|
|
|
const sellingPrice = getRandomInt(100, 500);
|
|
const deductible = sellingPrice - 1;
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: false,
|
|
deductible: {
|
|
repair: deductible
|
|
},
|
|
policyLookupSuccessful: true
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
},
|
|
mocks: {
|
|
$router: {
|
|
navigate: jest.fn()
|
|
}
|
|
}
|
|
};
|
|
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.setData({
|
|
availableLineItems: [
|
|
{
|
|
sellingPrice,
|
|
kitPrice: 0,
|
|
laborAmount: 0
|
|
}
|
|
]
|
|
});
|
|
|
|
// Act
|
|
wrapper.vm.forwardButtonAction();
|
|
|
|
// Assert
|
|
expect(wrapper.vm.$router.navigate)
|
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD, undefined);
|
|
});
|
|
test('If Verified ITAC and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
router: {
|
|
navigate: jest.fn()
|
|
},
|
|
mixins: [mockMixin]
|
|
};
|
|
const sellingPrice = getRandomInt(100, 500);
|
|
const deductible = sellingPrice + 1;
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: false,
|
|
deductible: {
|
|
repair: deductible
|
|
},
|
|
policyLookupSuccessful: true
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
},
|
|
mocks: {
|
|
$router: {
|
|
navigate: jest.fn()
|
|
}
|
|
}
|
|
}
|
|
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.setData({
|
|
availableLineItems: [
|
|
{
|
|
sellingPrice,
|
|
kitPrice: 0,
|
|
laborAmount: 0
|
|
}
|
|
],
|
|
selectedProvider: 'Safelite'
|
|
});
|
|
|
|
// Act
|
|
wrapper.vm.forwardButtonAction();
|
|
|
|
// Assert
|
|
expect(wrapper.vm.$router.navigate)
|
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, undefined);
|
|
});
|
|
test('If Verified ITAC, selected other shop, and TPA enabled, navigate forward w/ CLICKED_FORWARD_WITH_TPA_ENABLED', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
router: {
|
|
navigate: jest.fn()
|
|
},
|
|
mixins: [mockMixin]
|
|
};
|
|
const sellingPrice = getRandomInt(100, 500);
|
|
const deductible = sellingPrice + 1;
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: false,
|
|
deductible: {
|
|
repair: deductible
|
|
},
|
|
policyLookupSuccessful: true
|
|
}
|
|
},
|
|
issConfig: {
|
|
enableTPAFlow: true
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
},
|
|
mocks: {
|
|
$router: {
|
|
navigate: jest.fn()
|
|
}
|
|
}
|
|
}
|
|
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.setData({
|
|
availableLineItems: [
|
|
{
|
|
sellingPrice,
|
|
kitPrice: 0,
|
|
laborAmount: 0
|
|
}
|
|
],
|
|
selectedProvider: 'Other'
|
|
});
|
|
|
|
// Act
|
|
wrapper.vm.forwardButtonAction();
|
|
|
|
// Assert
|
|
expect(wrapper.vm.$router.navigate)
|
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED, undefined);
|
|
});
|
|
test('If Verified ITAC, selected other shop, and TPA disabled, navigate forward w/ CLICKED_FORWARD_WITH_TPA_DISABLED', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
router: {
|
|
navigate: jest.fn()
|
|
},
|
|
mixins: [mockMixin]
|
|
};
|
|
const sellingPrice = getRandomInt(100, 500);
|
|
const deductible = sellingPrice + 1;
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: false,
|
|
deductible: {
|
|
repair: deductible
|
|
},
|
|
policyLookupSuccessful: true
|
|
}
|
|
},
|
|
issConfig: {
|
|
enableTPAFlow: false
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
},
|
|
mocks: {
|
|
$router: {
|
|
navigate: jest.fn()
|
|
}
|
|
}
|
|
};
|
|
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.setData({
|
|
availableLineItems: [
|
|
{
|
|
sellingPrice,
|
|
kitPrice: 0,
|
|
laborAmount: 0
|
|
}
|
|
],
|
|
selectedProvider: 'Other'
|
|
});
|
|
|
|
// Act
|
|
wrapper.vm.forwardButtonAction();
|
|
|
|
// Assert
|
|
expect(wrapper.vm.$router.navigate)
|
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED, undefined);
|
|
});
|
|
test('If No Comp and selected Safelite, navigate forward with CLICKED_FORWARD scenario', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
router: {
|
|
navigate: jest.fn()
|
|
},
|
|
mixins: [mockMixin]
|
|
};
|
|
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
},
|
|
policy: {
|
|
noCoverage: true,
|
|
policyLookupSuccessful: true
|
|
}
|
|
}
|
|
};
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
},
|
|
mocks: {
|
|
$router: {
|
|
navigate: jest.fn()
|
|
}
|
|
}
|
|
};
|
|
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
wrapper.setData({
|
|
isVerified: false,
|
|
selectedProvider: 'Safelite'
|
|
});
|
|
|
|
// Act
|
|
wrapper.vm.forwardButtonAction();
|
|
|
|
// Assert
|
|
expect(wrapper.vm.$router.navigate)
|
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, undefined);
|
|
});
|
|
});
|
|
describe('ADAS', () => {
|
|
test('if Replace and parts require recalibration, isADAS should return true', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: false
|
|
},
|
|
lineItems: {
|
|
glassParts: [
|
|
{
|
|
requiresRecalibration: true
|
|
}
|
|
]
|
|
}
|
|
}
|
|
};
|
|
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.isADAS).toBeTruthy();
|
|
});
|
|
test('if Replace and parts do not require recalibration, isADAS should return false', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: false
|
|
},
|
|
lineItems: {
|
|
glassParts: [
|
|
{
|
|
requiresRecalibration: false
|
|
}
|
|
]
|
|
}
|
|
}
|
|
};
|
|
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.isADAS).toBeFalsy();
|
|
});
|
|
test('if Repair, isADAS should return true', () => {
|
|
// Arrange
|
|
const mountOptions = {
|
|
mixins: [mockMixin]
|
|
};
|
|
|
|
const mainInitialState = {
|
|
order: {
|
|
damage: {
|
|
isRepair: true
|
|
}
|
|
}
|
|
};
|
|
|
|
mountOptions.global = {
|
|
plugins: [createTestingPinia({
|
|
initialState: {
|
|
main: mainInitialState
|
|
}
|
|
})],
|
|
stubs: {
|
|
siteFooter: footerStub,
|
|
siteHeader: true,
|
|
recalModal: true,
|
|
contentGroupModal: true,
|
|
alert: true,
|
|
loadingModal: loadingModalStub
|
|
}
|
|
};
|
|
|
|
// Act
|
|
const wrapper = mount(coverageStatement, mountOptions);
|
|
|
|
// Assert
|
|
expect(wrapper.vm.isADAS).toBeFalsy();
|
|
});
|
|
});
|
|
describe.only('claim registration api call', () => {
|
|
it('claim registration not required => method not called', async () => {
|
|
// Arrange
|
|
const wrapper = setupMocks({});
|
|
|
|
const store = useMainStore();
|
|
store.isClaimRegistrationRequired = false;
|
|
|
|
const to = {
|
|
query: { issPage: getRandomString(4,10) }
|
|
};
|
|
const next = jest.fn();
|
|
|
|
// SUT
|
|
coverageStatement.beforeRouteEnter.call(wrapper.vm, to, undefined, next)
|
|
|
|
// Assert
|
|
expect(store.registerClaim).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it.only('claim registration required => register claim method called', async () => {
|
|
// Arrange
|
|
const sellingPrice = getRandomInt(50, 100);
|
|
const deductible = sellingPrice - 1;
|
|
const { wrapper } = setupMocks({
|
|
});
|
|
|
|
await wrapper.setData({
|
|
availableLineItems: [
|
|
{
|
|
sellingPrice,
|
|
kitPrice: 0,
|
|
laborAmount: 0
|
|
}
|
|
]
|
|
});
|
|
|
|
const store = useMainStore();
|
|
store.order.policy.policyLookupSuccessful = true;
|
|
store.isClaimRegistrationRequired = true;
|
|
store.order.policy.noCoverage = false;
|
|
store.order.damage.isRepair = true;
|
|
store.order.policy.deductible.repair = deductible;
|
|
|
|
const to = {
|
|
query: { issPage: getRandomString(4, 10) }
|
|
};
|
|
const next = jest.fn();
|
|
|
|
// SUT
|
|
coverageStatement.beforeRouteEnter.call(wrapper.vm, to, undefined, next);
|
|
// Assert
|
|
expect(store.registerClaim).toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|