Unit test updates
This commit is contained in:
parent
42b23a24a5
commit
17e48f17cf
2 changed files with 61 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ Object {
|
||||||
"salesTax": "SalesTaxWidget",
|
"salesTax": "SalesTaxWidget",
|
||||||
"servicePackage": "ServicePackageTitle",
|
"servicePackage": "ServicePackageTitle",
|
||||||
"subtotal": "SubtotalWidget",
|
"subtotal": "SubtotalWidget",
|
||||||
|
"total": "TotalWidget",
|
||||||
"vapsItemDescriptions": "VapsItemDescriptions",
|
"vapsItemDescriptions": "VapsItemDescriptions",
|
||||||
"warrantyText": "WarrantyCartItemTextWidget",
|
"warrantyText": "WarrantyCartItemTextWidget",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import { getHighestFullySatisfiedTier, getPackageContents } from '@/helpers/serv
|
||||||
import { getPriceOfLineItems } from '@/helpers/price-calculator.js';
|
import { getPriceOfLineItems } from '@/helpers/price-calculator.js';
|
||||||
import coverageStatuses from '@/constants/coverage-statuses';
|
import coverageStatuses from '@/constants/coverage-statuses';
|
||||||
import coverageType from '@/constants/coverage-type';
|
import coverageType from '@/constants/coverage-type';
|
||||||
|
import * as cartHelper from '@/helpers/cart-helper';
|
||||||
|
|
||||||
const VERIFYING_COVERAGE = 'Verifying coverage';
|
const VERIFYING_COVERAGE = 'Verifying coverage';
|
||||||
|
|
||||||
|
|
@ -341,21 +342,76 @@ describe('cart-dropdown component', () => {
|
||||||
});
|
});
|
||||||
describe('computed', () => {
|
describe('computed', () => {
|
||||||
describe('amountDue', () => {
|
describe('amountDue', () => {
|
||||||
test('returns 0 when showAsPaid is true', () => {
|
test('returns total when showAsPaid is false', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
const expectedAmount = 123.45;
|
||||||
const propsData = {
|
const propsData = {
|
||||||
showAsPaid: true
|
showAsPaid: false
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, propsData);
|
const { wrapper } = getMountedComponent({}, {}, propsData);
|
||||||
|
const totalSpy = jest.spyOn(cartHelper, 'getCartTotal').mockReturnValue(expectedAmount);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = wrapper.vm.amountDue;
|
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
|
// Assert
|
||||||
expect(result).toBe(0);
|
expect(result).toBe(0);
|
||||||
});
|
});
|
||||||
test('returns sum of subTotal and salesTax when showAsPaid is false', () => {
|
test('returns settled tender amount when showAsPaid is true', () => {
|
||||||
// TODO when subTotal and salesTax are finished
|
// 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', () => {
|
describe('availableLineItems', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue