diff --git a/src/iss-components/cart-dropdown/__snapshots__/cart-dropdown.spec.js.snap b/src/iss-components/cart-dropdown/__snapshots__/cart-dropdown.spec.js.snap index 8aa5504e..265928bc 100644 --- a/src/iss-components/cart-dropdown/__snapshots__/cart-dropdown.spec.js.snap +++ b/src/iss-components/cart-dropdown/__snapshots__/cart-dropdown.spec.js.snap @@ -20,6 +20,7 @@ Object { "salesTax": "SalesTaxWidget", "servicePackage": "ServicePackageTitle", "subtotal": "SubtotalWidget", + "total": "TotalWidget", "vapsItemDescriptions": "VapsItemDescriptions", "warrantyText": "WarrantyCartItemTextWidget", }, diff --git a/src/iss-components/cart-dropdown/cart-dropdown.spec.js b/src/iss-components/cart-dropdown/cart-dropdown.spec.js index b1ca9cdd..16692604 100644 --- a/src/iss-components/cart-dropdown/cart-dropdown.spec.js +++ b/src/iss-components/cart-dropdown/cart-dropdown.spec.js @@ -12,6 +12,7 @@ import { getHighestFullySatisfiedTier, getPackageContents } from '@/helpers/serv import { getPriceOfLineItems } from '@/helpers/price-calculator.js'; import coverageStatuses from '@/constants/coverage-statuses'; import coverageType from '@/constants/coverage-type'; +import * as cartHelper from '@/helpers/cart-helper'; const VERIFYING_COVERAGE = 'Verifying coverage'; @@ -341,21 +342,76 @@ describe('cart-dropdown component', () => { }); describe('computed', () => { describe('amountDue', () => { - test('returns 0 when showAsPaid is true', () => { + test('returns total when showAsPaid is false', () => { // Arrange + const expectedAmount = 123.45; const propsData = { - showAsPaid: true + showAsPaid: false }; const { wrapper } = getMountedComponent({}, {}, propsData); + const totalSpy = jest.spyOn(cartHelper, 'getCartTotal').mockReturnValue(expectedAmount); // Act const result = wrapper.vm.amountDue; + // Assert + expect(result).toBe(expectedAmount); + }); + test('returns total minus amount paid when showAsPaid is true', () => { + // Arrange + const total = 123.45; + const amountPaid = 23.45; + const expectedAmount = total - amountPaid; + const propsData = { + showAsPaid: true + }; + const storeData = { + order: { + settledTenderAmount: amountPaid + } + }; + const { wrapper } = getMountedComponent(storeData, {}, propsData); + const totalSpy = jest.spyOn(cartHelper, 'getCartTotal').mockReturnValue(total); + + // Act + const result = wrapper.vm.amountDue; + + // Assert + expect(result).toBe(expectedAmount); + }); + }); + describe('amountPaid', () => { + test('returns 0 when showAsPaid is false', () => { + // Arrange + const propsData = { + showAsPaid: false + }; + const { wrapper } = getMountedComponent({}, {}, propsData); + + // Act + const result = wrapper.vm.amountPaid; + // Assert expect(result).toBe(0); }); - test('returns sum of subTotal and salesTax when showAsPaid is false', () => { - // TODO when subTotal and salesTax are finished + test('returns settled tender amount when showAsPaid is true', () => { + // Arrange + const expectedAmount = 123.45; + const propsData = { + showAsPaid: true + }; + const storeData = { + order: { + settledTenderAmount: expectedAmount + } + }; + const { wrapper } = getMountedComponent(storeData, {}, propsData); + + // Act + const result = wrapper.vm.amountPaid; + + // Assert + expect(result).toBe(expectedAmount); }); }); describe('availableLineItems', () => {