diff --git a/src/layouts/coverage-statement/coverage-statement.spec.js b/src/layouts/coverage-statement/coverage-statement.spec.js index 12f0b49a..186c1799 100644 --- a/src/layouts/coverage-statement/coverage-statement.spec.js +++ b/src/layouts/coverage-statement/coverage-statement.spec.js @@ -830,19 +830,62 @@ describe('coverageStatement.vue-working', () => { }); }); describe('Computed', () => { - describe('formattedDeductible', () => {}); - describe('verifiedNoComp', () => {}); - describe('verifiedITAC', () => {}); - describe('verifiedDeductible', () => {}); + describe.only('verifiedNoComp', () => { + test.each([true, false])('returns false when policyLookupSuccessful false', (isNoComp) => { + + }); + test.each([true, false])('returns false when isNoComp false', (policyLookupSuccessful) => {}); + test('returns true when policyLookupSuccessful true and policyLookupSuccessful true', () => { + + }); + }); + describe('verifiedITAC', () => { + test('returns false when policyLookupSuccessful false', () => {}); + test('returns false when isNoComp true', () => {}); + test('returns false when deductibleValue equals totalServicePrice', () => {}); + test('returns false when deductibleValue less than totalServicePrice', () => {}); + }); + describe('verifiedDeductible', () => { + test('', () => { }); + test('', () => { }); + test('', () => { }); + test('', () => { }); + test('', () => { }); + test('', () => { }); + test('', () => { }); + }); describe('unverified', () => {}); describe('isADAS', () => {}); - describe('servicePriceForDisplay', () => {}); describe('itacCostSavings', () => {}); - describe('itacCostSavingsForDisplay', () => {}); describe('isQuoteDisplayed', () => {}); + describe('shouldRegisterClaim', () => {}); }); - describe('watchers', () => { + describe('methods', () => { + describe('arePagePrerequisitesValid', () => { + }); + test.each([ + [0, '$0.00'], + [1, '$1.00'], + [12, '$12.00'], + [1.2, '$1.20'], + [1.25, '$1.25'], + [1.254, '$1.25'], + [1.255, '$1.26'], + [-1, '-$1.00'] + ])('getFormattedAmount', (value, expected) => { + // Arrange + const { wrapper } = getMountedComponent(); + + // Act + const result = wrapper.vm.getFormattedAmount(value); + + // Assert + expect(result).toBe(expected); + }); + describe('navigateForward', () => { + + }); }); describe('ITAC flag', () => { test('ITAC flag updated once component is initialized', async () => { diff --git a/src/layouts/coverage-statement/coverage-statement.vue b/src/layouts/coverage-statement/coverage-statement.vue index 8776ebe1..ad578df1 100644 --- a/src/layouts/coverage-statement/coverage-statement.vue +++ b/src/layouts/coverage-statement/coverage-statement.vue @@ -35,7 +35,7 @@
- {{ formattedDeductible }} + {{ deductibleForDisplay }}
{{ deductibleText }}  - {{ formattedDeductible }} + {{ deductibleForDisplay }}
{ - useMainStore() - .setBailout( - to, - bailoutMessage.pricingResponseError( - availableLineItems.map((li) => li.partNumber), - { code: err.code, message: err.message, data: err.data } - ) - ); + setBailout(to, bailoutMessage.pricingResponseError( + availableLineItems.map((li) => li.partNumber), + { code: err.code, message: err.message, data: err.data } + )); hasBailedOut = true; next(`/?issPage=${issPageValues.BAILOUT_PAGE}`); }); @@ -292,7 +292,7 @@ export default { deductibleValue() { return useMainStore().order.currentDeductible; }, - formattedDeductible() { + deductibleForDisplay() { return this.getFormattedAmount(this.deductibleValue); }, registerClaimSuccessful() { @@ -347,6 +347,13 @@ export default { }, isQuoteDisplayed() { return this.verifiedITAC || this.verifiedNoComp; + }, + shouldRegisterClaim() { + return this.policyLookupSuccessful + && useMainStore().vehicle.policyVehicleId >= 0 + && useMainStore().isClaimRegistrationRequired + && !useMainStore().isClaimAlreadyRegistered + && (this.coveredAndServicePriceAboveOrEqualDeductible || this.verifiedITAC); } }, watch: { @@ -373,11 +380,7 @@ export default { }, async initializeComponent() { useMainStore().updatePolicyITACFlag(this.verifiedITAC); - if (this.policyLookupSuccessful - && useMainStore().vehicle.policyVehicleId >= 0 - && useMainStore().isClaimRegistrationRequired - && !useMainStore().isClaimAlreadyRegistered - && (this.coveredAndServicePriceAboveOrEqualDeductible || this.verifiedITAC)) { + if (this.shouldRegisterClaim) { await useMainStore().registerClaim()?.catch(() => {}); } this.$refs.loadingModal.hideModal(); @@ -385,38 +388,27 @@ export default { async navigateForward() { if (this.unverified || this.verifiedDeductible) { useMainStore().updateSupportingItems(this.supportingItems); - this.$router.navigate( - navigationScenarios.CLICKED_FORWARD, - this.$route, - {}, - { [routerParams.SAVE_SESSION_SYNCHRONOUS]: true } - ); + this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD); } else if (this.verifiedITAC || this.verifiedNoComp) { useMainStore().updateIsSafeliteProvider(this.selectedProvider === SAFELITE_PROVIDER); if (this.selectedProvider === SAFELITE_PROVIDER) { useMainStore().updateSupportingItems(this.supportingItems); - this.$router.navigate( - navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, - this.$route - ); + this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE); } else { - useMainStore().setBailout(this.$router.currentRoute, bailoutMessage.RequestCallback()); - this.$router.navigate( - navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP, - this.$route - ); + this.setBailoutWithMessage(bailoutMessage.RequestCallback()); + this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP); } } else { - useMainStore().setBailout( - this.$router.currentRoute, - bailoutMessage.coverageStatementInvalidState() - ); - this.$router.navigate( - navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE, - this.$route - ); + this.setBailoutWithMessage(bailoutMessage.coverageStatementInvalidState()); + this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE); } }, + setBailoutWithMessage(message) { + setBailout(this.$router.currentRoute, message); + }, + navigateWithScenario(scenario) { + this.$router.navigate(scenario, this.$route); + }, getTextFromCmsWithCustomIfStatements(widgetName, widgetField) { const rawText = this.getCmsContent(widgetName, widgetField); return processIfStatements(rawText, 'custom', this.getCustomValueFromString);