Adding test cases

This commit is contained in:
Michaela Brydon 2024-03-06 10:15:08 -05:00
parent 76c35865e4
commit 7757bc6cfd
2 changed files with 81 additions and 46 deletions

View file

@ -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 () => {

View file

@ -35,7 +35,7 @@
<div
v-if="verifiedDeductible"
class="d-flex justify-content-center cost">
{{ formattedDeductible }}
{{ deductibleForDisplay }}
</div>
<div
v-if="isQuoteDisplayed"
@ -46,7 +46,7 @@
v-if="verifiedITAC"
class="d-flex justify-content-center mb-4 deductible-text">
{{ deductibleText }}&nbsp;
<span class="text-success fw-bold">{{ formattedDeductible }}</span>
<span class="text-success fw-bold">{{ deductibleForDisplay }}</span>
</div>
<alert
v-if="verifiedITAC"
@ -134,6 +134,10 @@ import getPriceOfLineItems from '@/helpers/price-calculator.js';
const SAFELITE_PROVIDER = 'Safelite';
function setBailout(currentRoute, message) {
useMainStore().setBailout(currentRoute, message);
}
export default {
name: 'coverage-statement',
components: {
@ -181,14 +185,10 @@ export default {
await useMainStore().getFinalDeductible();
pricingResults = await useMainStore().getPriceOrderItems(availableLineItems)
.catch((err) => {
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);