Repurposing old tests
This commit is contained in:
parent
320093cf2d
commit
cba17fb676
1 changed files with 246 additions and 692 deletions
|
|
@ -10,7 +10,6 @@ import navigationScenarios from '@/router/router-constants/navigation-scenarios.
|
||||||
import { getRandomString, getRandomInt } from '@/helpers/data-generation.js';
|
import { getRandomString, getRandomInt } from '@/helpers/data-generation.js';
|
||||||
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 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';
|
import getPriceOfLineItems from '@/helpers/price-calculator.js';
|
||||||
|
|
||||||
|
|
@ -23,6 +22,8 @@ jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
processIfStatements: jest.fn()
|
processIfStatements: jest.fn()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const SAFELITE_PROVIDER = 'Safelite';
|
||||||
|
|
||||||
const mockMixin = {
|
const mockMixin = {
|
||||||
methods: {
|
methods: {
|
||||||
getCmsContent: jest.fn().mockImplementation(() => ''),
|
getCmsContent: jest.fn().mockImplementation(() => ''),
|
||||||
|
|
@ -89,697 +90,6 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
|
||||||
return { wrapper };
|
return { wrapper };
|
||||||
}
|
}
|
||||||
|
|
||||||
describe.skip('coverageStatement.vue', () => {
|
|
||||||
describe('method arePagePrerequisitesValid...', () => {
|
|
||||||
test('Should return true for valid page requisites if vin exists', () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = getMountedComponent({
|
|
||||||
order: {
|
|
||||||
vehicle: {
|
|
||||||
vin: getRandomString(5, 20)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(arePagePrerequisitesValid).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('Should return false for valid page requisites if vin is missing', () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = getMountedComponent({
|
|
||||||
order: {
|
|
||||||
vehicle: {
|
|
||||||
vin: null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(arePagePrerequisitesValid).not.toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Verified ITAC scenario', () => {
|
|
||||||
test('If policy lookup successful, not No Comp, and deductible > service price, verifiedITAC returns true', () => {
|
|
||||||
// Arrange
|
|
||||||
const sellingPrice = getRandomInt(100, 500);
|
|
||||||
const deductible = sellingPrice + 1;
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: false,
|
|
||||||
deductible: {
|
|
||||||
repair: deductible
|
|
||||||
},
|
|
||||||
policyLookupSuccessful: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
wrapper.setData({
|
|
||||||
availableLineItems: [
|
|
||||||
{
|
|
||||||
sellingPrice,
|
|
||||||
kitPrice: 0,
|
|
||||||
laborAmount: 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedITAC).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('If policy lookup unsuccessful, verifiedITAC returns false', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
policyLookupSuccessful: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedITAC).toBeFalsy();
|
|
||||||
});
|
|
||||||
test('If No Comp, verifiedITAC returns false', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedITAC).toBeFalsy();
|
|
||||||
});
|
|
||||||
test('If deductible < service price, verifiedITAC returns false', () => {
|
|
||||||
// Arrange
|
|
||||||
const sellingPrice = getRandomInt(100, 500);
|
|
||||||
const deductible = sellingPrice - 1;
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: false,
|
|
||||||
deductible: {
|
|
||||||
repair: deductible
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
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 sellingPrice = getRandomInt(100, 500);
|
|
||||||
const deductible = sellingPrice - 1;
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: false,
|
|
||||||
deductible: {
|
|
||||||
repair: deductible
|
|
||||||
},
|
|
||||||
policyLookupSuccessful: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
wrapper.setData({
|
|
||||||
availableLineItems: [
|
|
||||||
{
|
|
||||||
sellingPrice,
|
|
||||||
kitPrice: 0,
|
|
||||||
laborAmount: 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedDeductible).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('If policy lookup unsuccessful, verifiedDeductible returns false', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
policyLookupSuccessful: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
|
||||||
});
|
|
||||||
test('If No Comp, verifiedDeductible returns false', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
|
||||||
});
|
|
||||||
test('If service price < deductible, verifiedDeductible returns false', () => {
|
|
||||||
const sellingPrice = getRandomInt(100, 500);
|
|
||||||
const deductible = sellingPrice + 1;
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: false,
|
|
||||||
deductible: {
|
|
||||||
repair: deductible
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
wrapper.setData({
|
|
||||||
availableLineItems: [
|
|
||||||
{
|
|
||||||
sellingPrice,
|
|
||||||
kitPrice: 0,
|
|
||||||
laborAmount: 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
|
||||||
});
|
|
||||||
test('If deductible is null, verifiedDeductible returns false', () => {
|
|
||||||
const sellingPrice = getRandomInt(100, 500);
|
|
||||||
const deductible = null;
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: false,
|
|
||||||
deductible: {
|
|
||||||
repair: deductible
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
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 mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: true,
|
|
||||||
policyLookupSuccessful: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedNoComp).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('If noCoverage = false, verifiedNoComp returns false', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedNoComp).toBeFalsy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Unverified scenario', () => {
|
|
||||||
test('If policyLookupSuccessful false, unverified returns true', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
policyLookupSuccessful: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.unverified).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('If policyLookupSuccessful is true, unverified returns false', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
policyLookupSuccessful: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.unverified).toBeFalsy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Navigation', () => {
|
|
||||||
test('If Unverified, navigate forward with CLICKED_FORWARD scenario', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
policyLookupSuccessful: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
wrapper.vm.forwardButtonAction();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.$router.navigate)
|
|
||||||
.toHaveBeenCalledWith(
|
|
||||||
navigationScenarios.CLICKED_FORWARD,
|
|
||||||
undefined,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
|
|
||||||
// Arrange
|
|
||||||
const sellingPrice = getRandomInt(100, 500);
|
|
||||||
const deductible = sellingPrice - 1;
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: false,
|
|
||||||
deductible: {
|
|
||||||
repair: deductible
|
|
||||||
},
|
|
||||||
policyLookupSuccessful: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
wrapper.setData({
|
|
||||||
availableLineItems: [
|
|
||||||
{
|
|
||||||
sellingPrice,
|
|
||||||
kitPrice: 0,
|
|
||||||
laborAmount: 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
wrapper.vm.forwardButtonAction();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.$router.navigate)
|
|
||||||
.toHaveBeenCalledWith(
|
|
||||||
navigationScenarios.CLICKED_FORWARD,
|
|
||||||
undefined,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
test('If Verified ITAC and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
|
||||||
// Arrange
|
|
||||||
const sellingPrice = getRandomInt(100, 500);
|
|
||||||
const deductible = sellingPrice + 1;
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: false,
|
|
||||||
deductible: {
|
|
||||||
repair: deductible
|
|
||||||
},
|
|
||||||
policyLookupSuccessful: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
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,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
test('If Verified ITAC, selected other shop, and TPA enabled, navigate forward w/ CLICKED_FORWARD_WITH_TPA_ENABLED', () => {
|
|
||||||
// Arrange
|
|
||||||
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
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
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,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
test('If Verified ITAC, selected other shop, and TPA disabled, navigate forward w/ CLICKED_FORWARD_WITH_TPA_DISABLED', () => {
|
|
||||||
// Arrange
|
|
||||||
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
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
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,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
test('If No Comp and selected Safelite, navigate forward with CLICKED_FORWARD scenario', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: true,
|
|
||||||
policyLookupSuccessful: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
wrapper.setData({
|
|
||||||
isVerified: false,
|
|
||||||
selectedProvider: 'Safelite'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
wrapper.vm.forwardButtonAction();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.$router.navigate)
|
|
||||||
.toHaveBeenCalledWith(
|
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
|
||||||
undefined,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('ADAS', () => {
|
|
||||||
test('if Replace and parts require recalibration, isADAS should return true', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: false
|
|
||||||
},
|
|
||||||
lineItems: {
|
|
||||||
glassParts: [
|
|
||||||
{
|
|
||||||
requiresRecalibration: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.isADAS).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('if Replace and parts do not require recalibration, isADAS should return false', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: false
|
|
||||||
},
|
|
||||||
lineItems: {
|
|
||||||
glassParts: [
|
|
||||||
{
|
|
||||||
requiresRecalibration: false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.isADAS).toBeFalsy();
|
|
||||||
});
|
|
||||||
test('if Repair, isADAS should return true', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.isADAS).toBeFalsy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('claim registration api call', () => {
|
|
||||||
it('claim registration not required => method not called', async () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = getMountedComponent({
|
|
||||||
issConfig: {
|
|
||||||
isClaimRegistrationRequired: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.mainStore.registerClaim).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('claim registration required => register claim method called', async () => {
|
|
||||||
// Arrange
|
|
||||||
const sellingPrice = getRandomInt(50, 100);
|
|
||||||
const deductible = sellingPrice - 1;
|
|
||||||
const initialStore = {
|
|
||||||
order: {
|
|
||||||
policy: {
|
|
||||||
policyLookupSuccessful: true,
|
|
||||||
noCoverage: false,
|
|
||||||
deductible: {
|
|
||||||
repair: deductible
|
|
||||||
}
|
|
||||||
},
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
issConfig: {
|
|
||||||
isClaimRegistrationRequired: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const mockStoreActions = () => {
|
|
||||||
useMainStore().getWipers = jest.fn().mockImplementation(() => Promise.resolve());
|
|
||||||
useMainStore().getRainDefense = jest.fn().mockImplementation(() => Promise.resolve());
|
|
||||||
useMainStore().getSupportingItems = jest.fn().mockImplementation(() => Promise.resolve());
|
|
||||||
useMainStore().getPriceOrderItems = jest.fn().mockImplementation(() => Promise.resolve([
|
|
||||||
{
|
|
||||||
sellingPrice,
|
|
||||||
kitPrice: 0,
|
|
||||||
laborAmount: 0
|
|
||||||
}
|
|
||||||
]));
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions);
|
|
||||||
const next = (method) => { method(wrapper.vm); };
|
|
||||||
|
|
||||||
// Act
|
|
||||||
coverageStatement.beforeRouteEnter.call(wrapper.vm, undefined, undefined, next);
|
|
||||||
for (let i = 0; i < 7; i++) {
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
|
||||||
await nextTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.mainStore.registerClaim).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('coverageStatement.vue-working', () => {
|
describe('coverageStatement.vue-working', () => {
|
||||||
test('returns the initial data', () => {
|
test('returns the initial data', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -1591,6 +901,180 @@ describe('coverageStatement.vue-working', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(expected);
|
expect(result).toBe(expected);
|
||||||
});
|
});
|
||||||
|
describe('navigateForward', () => {
|
||||||
|
const servicePrice = 82;
|
||||||
|
beforeEach(() => {
|
||||||
|
getPriceOfLineItems.mockImplementation(() => servicePrice);
|
||||||
|
});
|
||||||
|
test('If Unverified, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: false
|
||||||
|
},
|
||||||
|
currentDeductible: null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigate)
|
||||||
|
.toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_FORWARD,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||||
|
// Arrange
|
||||||
|
const deductible = servicePrice - 1;
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
},
|
||||||
|
currentDeductible: deductible
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
// 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 deductible = servicePrice + 1;
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
},
|
||||||
|
currentDeductible: deductible
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
wrapper.setData({
|
||||||
|
selectedProvider: SAFELITE_PROVIDER
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigate)
|
||||||
|
.toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test('If Verified ITAC, selected other shop, navigate forward w/ CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP', () => {
|
||||||
|
// Arrange
|
||||||
|
const deductible = servicePrice + 1;
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
},
|
||||||
|
currentDeductible: deductible
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
wrapper.setData({
|
||||||
|
selectedProvider: 'Other'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigate)
|
||||||
|
.toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test('If No Comp and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
wrapper.setData({
|
||||||
|
selectedProvider: SAFELITE_PROVIDER
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigate)
|
||||||
|
.toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test('If No comp and selected other shop, navigate forward with CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP ', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
wrapper.setData({
|
||||||
|
selectedProvider: 'other'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigate)
|
||||||
|
.toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('ITAC flag', () => {
|
describe('ITAC flag', () => {
|
||||||
test('ITAC flag updated once component is initialized', async () => {
|
test('ITAC flag updated once component is initialized', async () => {
|
||||||
|
|
@ -1667,4 +1151,74 @@ describe('coverageStatement.vue-working', () => {
|
||||||
expect(wrapper.vm.mainStore.registerClaim).toHaveBeenCalledTimes(0);
|
expect(wrapper.vm.mainStore.registerClaim).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('claim registration api call', () => {
|
||||||
|
it('claim registration not required => method not called', async () => {
|
||||||
|
// Arrange
|
||||||
|
const mockStoreActions = () => {
|
||||||
|
useMainStore().getWipers = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
useMainStore().getRainDefense = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
useMainStore().getSupportingItems = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
useMainStore().getPriceOrderItems = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent({
|
||||||
|
issConfig: {
|
||||||
|
isClaimRegistrationRequired: false
|
||||||
|
}
|
||||||
|
}, {}, mockStoreActions);
|
||||||
|
const next = (method) => { method(wrapper.vm); };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
coverageStatement.beforeRouteEnter.call(wrapper.vm, undefined, undefined, next);
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await nextTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.mainStore.registerClaim).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('claim registration required => register claim method called', async () => {
|
||||||
|
// Arrange
|
||||||
|
const servicePrice = 7283;
|
||||||
|
const deductible = servicePrice - 1;
|
||||||
|
const initialStore = {
|
||||||
|
order: {
|
||||||
|
payment: {
|
||||||
|
insuranceCoverage: { claimNumber: null }
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
policyLookupSuccessful: true,
|
||||||
|
noCoverage: false
|
||||||
|
},
|
||||||
|
vehicle: {
|
||||||
|
policyVehicleId: 1
|
||||||
|
},
|
||||||
|
currentDeductible: deductible
|
||||||
|
},
|
||||||
|
issConfig: {
|
||||||
|
isClaimRegistrationRequired: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getPriceOfLineItems.mockImplementation(() => servicePrice);
|
||||||
|
const mockStoreActions = () => {
|
||||||
|
useMainStore().getWipers = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
useMainStore().getRainDefense = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
useMainStore().getSupportingItems = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
useMainStore().getPriceOrderItems = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions);
|
||||||
|
const next = (method) => { method(wrapper.vm); };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
coverageStatement.beforeRouteEnter.call(wrapper.vm, undefined, undefined, next);
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await nextTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.mainStore.registerClaim).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue