update unit tests to match deductible store value structure
This commit is contained in:
parent
1e72856db9
commit
6854a2b489
6 changed files with 158 additions and 49 deletions
|
|
@ -239,8 +239,13 @@ describe('cart-helper', () => {
|
|||
describe('getDeductible', () => {
|
||||
test('Returns deductible on the order', () => {
|
||||
// Arrange
|
||||
const deductible = 100;
|
||||
const deductible = {
|
||||
replace: 100
|
||||
};
|
||||
const order = {
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
currentDeductible: deductible
|
||||
};
|
||||
|
||||
|
|
@ -249,7 +254,7 @@ describe('cart-helper', () => {
|
|||
|
||||
// Assert
|
||||
expect(result).not.toBeNull();
|
||||
expect(result).toBe(deductible);
|
||||
expect(result).toBe(deductible.replace);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -349,7 +354,12 @@ describe('cart-helper', () => {
|
|||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
currentDeductible: {
|
||||
replace: 100
|
||||
},
|
||||
lineItems: nullLineItems
|
||||
};
|
||||
|
||||
|
|
@ -373,7 +383,12 @@ describe('cart-helper', () => {
|
|||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
currentDeductible: {
|
||||
replace: 100
|
||||
},
|
||||
lineItems: emptyLineItems
|
||||
};
|
||||
|
||||
|
|
@ -397,7 +412,12 @@ describe('cart-helper', () => {
|
|||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
currentDeductible: {
|
||||
replace: 100
|
||||
},
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
|
|
@ -495,7 +515,12 @@ describe('cart-helper', () => {
|
|||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
currentDeductible: {
|
||||
replace: 100
|
||||
},
|
||||
lineItems: nullLineItems
|
||||
};
|
||||
|
||||
|
|
@ -520,7 +545,12 @@ describe('cart-helper', () => {
|
|||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
currentDeductible: {
|
||||
replace: 100
|
||||
},
|
||||
lineItems: emptyLineItems
|
||||
};
|
||||
|
||||
|
|
@ -545,7 +575,12 @@ describe('cart-helper', () => {
|
|||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 100,
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
currentDeductible: {
|
||||
replace: 100
|
||||
},
|
||||
lineItems: defaultLineItems
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,13 @@ const initialStore = {
|
|||
lastName: 'Test',
|
||||
servicePhone: '111-111-1111',
|
||||
emailAddress: 'test@email.com'
|
||||
},
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
currentDeductible: {
|
||||
replace: 100,
|
||||
repair: 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -123,14 +130,20 @@ const sessionStorage = {
|
|||
vaps: []
|
||||
},
|
||||
policy: {},
|
||||
damage: {},
|
||||
damage: {
|
||||
isRepair: false
|
||||
},
|
||||
vehicle: {
|
||||
year: 2000,
|
||||
make: 'Honda',
|
||||
model: 'Civic'
|
||||
},
|
||||
customer: {},
|
||||
customerPortalLoginToken: 'token'
|
||||
customerPortalLoginToken: 'token',
|
||||
currentDeductible: {
|
||||
replace: 100,
|
||||
repair: 0
|
||||
}
|
||||
};
|
||||
|
||||
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}, mixin = mockMixin) {
|
||||
|
|
|
|||
|
|
@ -232,7 +232,9 @@ describe('payment-method.vue', () => {
|
|||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
currentDeductible: 123
|
||||
currentDeductible: {
|
||||
replace: 123
|
||||
}
|
||||
},
|
||||
issConfig: {
|
||||
isClaimRegistrationRequired: true,
|
||||
|
|
@ -286,7 +288,7 @@ describe('payment-method.vue', () => {
|
|||
test('returns true when coverageStatus is verified and deductibleTotal = 0', () => {
|
||||
// Arrange
|
||||
store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED;
|
||||
store.order.currentDeductible = 0;
|
||||
store.order.currentDeductible.replace = 0;
|
||||
const wrapper = setupMocks({}, store, mixin);
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ describe('tpa-submit', () => {
|
|||
serviceLocation: {
|
||||
provider: {
|
||||
companyName: providerCompanyName
|
||||
}
|
||||
}
|
||||
},
|
||||
contactInfo: {
|
||||
firstName,
|
||||
|
|
@ -431,7 +431,7 @@ describe('tpa-submit', () => {
|
|||
serviceLocation: {
|
||||
provider: {
|
||||
companyName: providerCompanyName
|
||||
}
|
||||
}
|
||||
},
|
||||
contactInfo: {
|
||||
firstName,
|
||||
|
|
@ -520,7 +520,9 @@ describe('tpa-submit', () => {
|
|||
// Arrange
|
||||
const initialStore = {
|
||||
order: {
|
||||
currentDeductible: storeValue
|
||||
currentDeductible: {
|
||||
replace: storeValue
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
|
|
@ -568,7 +570,10 @@ describe('tpa-submit', () => {
|
|||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
},
|
||||
currentDeductible: deductible
|
||||
currentDeductible: {
|
||||
replace: deductible,
|
||||
repair: deductible
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
|
|
@ -596,7 +601,10 @@ describe('tpa-submit', () => {
|
|||
insuranceCoverage: {
|
||||
coverageStatus: status
|
||||
},
|
||||
currentDeductible: deductible
|
||||
currentDeductible: {
|
||||
replace: deductible,
|
||||
repair: deductible
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(initialStore);
|
||||
|
|
|
|||
|
|
@ -16,12 +16,11 @@
|
|||
<alert
|
||||
ref="alertIncomplete"
|
||||
alertClass="alert-warning"
|
||||
:cmsWidgetName="widget.alertIncomplete"
|
||||
/>
|
||||
:cmsWidgetName="widget.alertIncomplete" />
|
||||
<textBlock
|
||||
ref="subHeaderTitle"
|
||||
:customText="subHeaderTitle"
|
||||
class="tpa-submit-title"/>
|
||||
class="tpa-submit-title" />
|
||||
<textBlock
|
||||
id="tpaSubmitSubHeaderBodyOne"
|
||||
ref="tpaSubmitSubHeaderBodyOne"
|
||||
|
|
@ -40,9 +39,15 @@
|
|||
:headerText="recalModalContent.headerText"
|
||||
:footerButtonText="recalModalContent.footerButtonText"
|
||||
@footerButtonEvent="closeRecalModal">
|
||||
<div class="recal-modal-subheader">{{ recalModalContent.subHeaderText }}</div>
|
||||
<img class="recal-modal-image" :src="recalModalContent.image" />
|
||||
<div class="recal-modal-body" v-html="recalModalContent.bodyText"></div>
|
||||
<div class="recal-modal-subheader">
|
||||
{{ recalModalContent.subHeaderText }}
|
||||
</div>
|
||||
<img
|
||||
class="recal-modal-image"
|
||||
:src="recalModalContent.image" />
|
||||
<div
|
||||
class="recal-modal-body"
|
||||
v-html="recalModalContent.bodyText"></div>
|
||||
</modal>
|
||||
<hr />
|
||||
<div id="serviceSummarySection">
|
||||
|
|
@ -155,7 +160,7 @@ export default {
|
|||
alertIncomplete: 'AlertIncompleteWidget',
|
||||
alertRecalWarning: 'AlertRecalWarningWidget',
|
||||
editShopLinkText: 'EditShopLinkTextWidget',
|
||||
contactDetails: 'ContactDetailsSectionWidget'
|
||||
contactDetails: 'ContactDetailsSectionWidget'
|
||||
},
|
||||
modalPositions
|
||||
};
|
||||
|
|
@ -269,7 +274,7 @@ export default {
|
|||
bodyText: this.getCmsContent(widgetName, widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT),
|
||||
footerButtonText: this.getCmsContent(widgetName, widgetFields.CONTENT_GROUP_WIDGET.FOOTER_TEXT),
|
||||
image: this.getCmsContent(widgetName, widgetFields.CONTENT_GROUP_WIDGET.IMAGE)
|
||||
}
|
||||
};
|
||||
},
|
||||
recalibrationRequired() {
|
||||
return this.mainStore.hasRecalibrationPart;
|
||||
|
|
@ -281,9 +286,9 @@ export default {
|
|||
}
|
||||
return {
|
||||
glassShop: this.getPreferredShopTitle,
|
||||
contactPhone: contactPhone,
|
||||
contactPhone,
|
||||
contactEmail: this.mainStore.contactInfo.emailAddress ?? ''
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -293,7 +298,7 @@ export default {
|
|||
this.getPreferredShopTitle,
|
||||
this.getPreferredShopLines,
|
||||
this.getEditShopLinkText,
|
||||
() => this.navigate(this.navigationScenarios.EDIT_PREFERRED_SHOP),
|
||||
() => this.navigate(this.navigationScenarios.EDIT_PREFERRED_SHOP)
|
||||
),
|
||||
// eslint-disable-next-line max-len
|
||||
this.getSection(
|
||||
|
|
@ -306,7 +311,7 @@ export default {
|
|||
},
|
||||
getSection(title, lines, editLinkText, onClick) {
|
||||
return {
|
||||
title: title,
|
||||
title,
|
||||
lines,
|
||||
editLinkText,
|
||||
onClickEdit: onClick
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import coverageStatuses from '@/constants/coverage-statuses.js';
|
|||
import { paymentMethods } from '@/constants/payment-method-constants';
|
||||
import endpoints from '@/constants/endpoints';
|
||||
import { AppointmentTypeStrings } from '@/constants/schedule-constants';
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
import { getEnumName } from '@/helpers/unit-test-helper';
|
||||
|
||||
|
|
@ -227,6 +226,10 @@ describe('Store', () => {
|
|||
test(`CoverageType is set to expected ${getEnumName(coverageType, expected)} when vehicle noCoverage is ${noCoverage} and enableNoCompQuote is ${enableNoCompQuote}`, () => {
|
||||
// Arrange
|
||||
store.issConfig.enableNoCompQuote = enableNoCompQuote;
|
||||
store.order.currentDeductible = {
|
||||
replace: 500,
|
||||
repair: 0
|
||||
};
|
||||
const vehicleCoverage = {
|
||||
noCoverage
|
||||
};
|
||||
|
|
@ -407,6 +410,10 @@ describe('Store', () => {
|
|||
}
|
||||
};
|
||||
store.order.insuranceCoverage.coverageType = coverageType.NO_COMP;
|
||||
store.order.currentDeductible = {
|
||||
replace: 500,
|
||||
repair: 0
|
||||
};
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
|
|
@ -434,6 +441,10 @@ describe('Store', () => {
|
|||
}
|
||||
};
|
||||
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||
store.order.currentDeductible = {
|
||||
replace: 500,
|
||||
repair: 0
|
||||
};
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
|
|
@ -453,6 +464,10 @@ describe('Store', () => {
|
|||
const error = 'register claim error';
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||
store.order.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||
store.order.currentDeductible = {
|
||||
replace: 500,
|
||||
repair: 0
|
||||
};
|
||||
|
||||
// Act
|
||||
await store.registerClaim().catch((e) => {
|
||||
|
|
@ -501,7 +516,7 @@ describe('Store', () => {
|
|||
home: homePhone,
|
||||
service: servicePhone,
|
||||
alternative: altPhone,
|
||||
extension: extension
|
||||
extension
|
||||
});
|
||||
|
||||
// Assert
|
||||
|
|
@ -670,10 +685,22 @@ describe('Store', () => {
|
|||
const policyZipCode = getRandomString(6, 6);
|
||||
const status = getRandomEnum(coverageStatuses);
|
||||
const type = getRandomEnum(coverageType);
|
||||
const originalDeductible = getRandomString(6, 6);
|
||||
const currentDeductible = getRandomString(6, 6);
|
||||
store.order.originalDeductible = originalDeductible;
|
||||
store.order.currentDeductible = currentDeductible;
|
||||
const originalDeductible = {
|
||||
replace: 500,
|
||||
repair: 0
|
||||
};
|
||||
const currentDeductible = {
|
||||
replace: 500,
|
||||
repair: 0
|
||||
};
|
||||
store.order.originalDeductible = {
|
||||
replace: originalDeductible.replace,
|
||||
repair: originalDeductible.repair
|
||||
};
|
||||
store.order.currentDeductible = {
|
||||
replace: currentDeductible.replace,
|
||||
repair: currentDeductible.repair
|
||||
};
|
||||
store.order.customer.firstName = customerFirstName;
|
||||
store.order.customer.lastName = customerLastName;
|
||||
store.order.customer.emailAddress = customerEmail;
|
||||
|
|
@ -684,6 +711,7 @@ describe('Store', () => {
|
|||
store.order.policy.policyZipCode = policyZipCode;
|
||||
store.order.insuranceCoverage.coverageStatus = status;
|
||||
store.order.insuranceCoverage.coverageType = type;
|
||||
store.order.damage.isRepair = false;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
|
|
@ -702,8 +730,8 @@ describe('Store', () => {
|
|||
}),
|
||||
policyNumber,
|
||||
policyZipCode,
|
||||
originalDeductible,
|
||||
currentDeductible
|
||||
originalDeductible: originalDeductible.replace,
|
||||
currentDeductible: currentDeductible.replace
|
||||
}),
|
||||
insuranceCoverage: expect.objectContaining({
|
||||
coverageStatus: status,
|
||||
|
|
@ -1717,8 +1745,8 @@ describe('Store', () => {
|
|||
const manualGlassNames = [location];
|
||||
const policyState = getRandomString(2, 2);
|
||||
const status = getRandomString(6, 8);
|
||||
const currentDeductible = getRandomInt(0, 5000);
|
||||
const originalDeductible = getRandomInt(0, 5000);
|
||||
const currentDeductible = 500;
|
||||
const originalDeductible = 500;
|
||||
const isRepair = getRandomBoolean();
|
||||
const policyNumber = getRandomString(10, 20);
|
||||
const insuredFirstName = getRandomString(10, 20);
|
||||
|
|
@ -1730,8 +1758,14 @@ describe('Store', () => {
|
|||
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.order.parentAccountNumber = parentAccountNumber;
|
||||
store.order.currentDeductible = currentDeductible;
|
||||
store.order.originalDeductible = originalDeductible;
|
||||
store.order.currentDeductible = {
|
||||
replace: currentDeductible,
|
||||
repair: currentDeductible
|
||||
};
|
||||
store.order.originalDeductible = {
|
||||
replace: originalDeductible,
|
||||
repair: originalDeductible
|
||||
};
|
||||
store.order.policy.status = status;
|
||||
store.order.customer.address.state = policyState;
|
||||
store.order.damage.isRepair = isRepair;
|
||||
|
|
@ -1827,8 +1861,14 @@ describe('Store', () => {
|
|||
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.order.parentAccountNumber = parentAccountNumber;
|
||||
store.order.currentDeductible = currentDeductible;
|
||||
store.order.originalDeductible = originalDeductible;
|
||||
store.order.currentDeductible = {
|
||||
replace: currentDeductible,
|
||||
repair: currentDeductible
|
||||
};
|
||||
store.order.originalDeductible = {
|
||||
replace: originalDeductible,
|
||||
repair: originalDeductible
|
||||
};
|
||||
store.order.policy.status = status;
|
||||
store.order.customer.address.state = policyState;
|
||||
store.order.policy.endorsementQuestionAnswers = endorsementAnswers;
|
||||
|
|
@ -1898,23 +1938,29 @@ describe('Store', () => {
|
|||
describe('updateDeductible method', () => {
|
||||
it('final deductible is saved as currentDeductible in store', () => {
|
||||
// Arrange
|
||||
const finalDeductible = getRandomInt(0, 5000);
|
||||
store.order.damage.isRepair = false;
|
||||
const deductibleInfo = {
|
||||
deductible: 500
|
||||
};
|
||||
|
||||
// Act
|
||||
store.updateDeductible(finalDeductible);
|
||||
store.updateDeductible(deductibleInfo);
|
||||
|
||||
// Assert
|
||||
expect(store.order.currentDeductible).toEqual(finalDeductible);
|
||||
expect(store.order.currentDeductible.replace).toEqual(deductibleInfo.deductible);
|
||||
});
|
||||
it('null final deductible => currentDeductible in store set to null', () => {
|
||||
// Arrange
|
||||
const finalDeductible = null;
|
||||
store.order.damage.isRepair = false;
|
||||
const deductibleInfo = {
|
||||
deductible: null
|
||||
};
|
||||
|
||||
// Act
|
||||
store.updateDeductible(finalDeductible);
|
||||
store.updateDeductible(deductibleInfo);
|
||||
|
||||
// Assert
|
||||
expect(store.order.currentDeductible).toEqual(finalDeductible);
|
||||
expect(store.order.currentDeductible.replace).toEqual(deductibleInfo.deductible);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue