partial test addition

This commit is contained in:
Michaela Brydon 2024-03-29 09:17:44 -04:00
parent 653cb5e9ca
commit 5133bf5697
2 changed files with 37 additions and 10 deletions

View file

@ -458,6 +458,13 @@ describe('cart-dropdown component', () => {
}); });
}); });
describe.todo('subTotal', () => { describe.todo('subTotal', () => {
test('when not no comp and not itac, includes deductible price', () => {});
test('when no comp, includes base service price', () => {});
test('when ITAC, includes base service price', () => {});
test('no issue when nonServicePackageCartItems null', () => {});
test('when nonServicePackageCartItems non empty, sums appropriately', () => {});
test('when deductible included, sums all prices appropriately', () => {});
test('when base service price included, sums all prices appropriately', () => {});
}); });
describe.todo('salesTax', () => {}); describe.todo('salesTax', () => {});
describe('availableLineItems', () => { describe('availableLineItems', () => {
@ -773,7 +780,18 @@ describe('cart-dropdown component', () => {
})); }));
}); });
}); });
describe.todo('nonServicePackageCartItems', () => {}); describe.todo('nonServicePackageCartItems', () => {
test('when recycleFee, includes recycle fee', () => {});
test('when mobileFee, includes mobile fee', () => {});
test('front wiper not included when front wiper in service package', () => {});
test('rear wiper not included when rear wiper in service package', () => {});
test('rain defense not included when rain defense in service package', () => {});
test('front wiper included when not in service package and in vaps', () => {});
test('rear wiper included when not in service package and in vaps', () => {});
test('rain defense included when not in service package and in vaps', () => {});
test('item in vaps outside front wiper, rear wiper, and rain defense never included', () => {});
test('returns expected when multiple variables apply', () => {});
});
describe('servicePackageLabelWidget', () => { describe('servicePackageLabelWidget', () => {
test.each([ test.each([
[null], [null],
@ -996,7 +1014,12 @@ describe('cart-dropdown component', () => {
expect(result.name).toBe(expectedName); expect(result.name).toBe(expectedName);
}); });
}); });
describe.todo('packagePrice', () => {}); describe.todo('packagePrice', () => {
test('returns 0 when servicePackageCartItems is null', () => {});
test('returns 0 when servicePackageCartItems is empty', () => {});
test('returns expected when servicePackageCartItems not empty', () => {});
test('returns expected when servicePackageCartItems has one item', () => {});
});
}); });
describe('method', () => { describe('method', () => {
describe('getDisplayed', () => { describe('getDisplayed', () => {
@ -1353,8 +1376,10 @@ describe('cart-dropdown component', () => {
expect(result.subTotal).toBe(expectedSubtotal); expect(result.subTotal).toBe(expectedSubtotal);
}); });
}); });
describe('removeItem', () => { describe.todo('removeItem', () => {
// TODO when written test('when isVap false, updateVaps not called', () => {});
test('when isVap true, vapsInOrder is expected', () => {});
test('when isVap true and vapsInOrder null, vapsInOrder becomes []', () => {});
}); });
}); });
}); });

View file

@ -214,10 +214,10 @@ export default {
const basePrice = !this.isNoComp && !this.isITAC const basePrice = !this.isNoComp && !this.isITAC
? this.deductible ? this.deductible
: this.baseServicePrice; : this.baseServicePrice;
const nonPackageCartItemsPrice = this.nonServicePackageCartItems.reduce( const nonPackageCartItemsPrice = this.nonServicePackageCartItems?.reduce(
(accumulator, cartItem) => accumulator + cartItem.subTotal, (accumulator, cartItem) => accumulator + cartItem.subTotal,
0 0
); ) ?? 0;
return basePrice + nonPackageCartItemsPrice + this.packagePrice; return basePrice + nonPackageCartItemsPrice + this.packagePrice;
}, },
salesTax() { salesTax() {
@ -266,7 +266,9 @@ export default {
return items; return items;
}, },
nonServicePackageCartItems() { nonServicePackageCartItems() {
const vapsLineItemsNotInPackage = this.vapsInOrder.filter((vap) => !this.partTypesInServicePackage.includes(vap.partType)); const vapsLineItemsNotInPackage = this.vapsInOrder
?.filter((vap) => !this.partTypesInServicePackage.includes(vap.partType))
?? [];
const vapsCartItemsNotInPackage = vapsLineItemsNotInPackage.map((lineItem) => { const vapsCartItemsNotInPackage = vapsLineItemsNotInPackage.map((lineItem) => {
switch (lineItem.partType) { switch (lineItem.partType) {
case partTypeStrings.FRONT_WIPER: case partTypeStrings.FRONT_WIPER:
@ -298,10 +300,10 @@ export default {
return this.getCartItemForVapsPart(partTypeStrings.RAIN_DEFENSE); return this.getCartItemForVapsPart(partTypeStrings.RAIN_DEFENSE);
}, },
packagePrice() { packagePrice() {
return this.servicePackageCartItems.reduce( return this.servicePackageCartItems?.reduce(
(accumulator, cartItem) => accumulator + cartItem.subTotal, (accumulator, cartItem) => accumulator + cartItem.subTotal,
0 0
); ) ?? 0;
}, },
amountDueLabel() { amountDueLabel() {
return this.getCmsContent(this.widget.amountDue, widgetFields.TEXT_BLOCK_WIDGET.TEXT); return this.getCmsContent(this.widget.amountDue, widgetFields.TEXT_BLOCK_WIDGET.TEXT);
@ -405,7 +407,7 @@ export default {
}, },
removeItem(partType, isVap) { removeItem(partType, isVap) {
if (isVap) { if (isVap) {
this.vapsInOrder = this.vapsInOrder.filter((vap) => vap.partType !== partType); this.vapsInOrder = this.vapsInOrder?.filter((vap) => vap?.partType !== partType) ?? [];
useMainStore().updateVaps(this.vapsInOrder); useMainStore().updateVaps(this.vapsInOrder);
} }
// NOTE Currently only vaps can be removed // NOTE Currently only vaps can be removed