Unit test updates

This commit is contained in:
Alex Humphries 2026-02-27 17:00:38 -05:00
parent 42b23a24a5
commit 17e48f17cf
2 changed files with 61 additions and 4 deletions

View file

@ -20,6 +20,7 @@ Object {
"salesTax": "SalesTaxWidget",
"servicePackage": "ServicePackageTitle",
"subtotal": "SubtotalWidget",
"total": "TotalWidget",
"vapsItemDescriptions": "VapsItemDescriptions",
"warrantyText": "WarrantyCartItemTextWidget",
},

View file

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