Finishing up tests
This commit is contained in:
parent
5ccd00329f
commit
2616300bf2
2 changed files with 564 additions and 115 deletions
|
|
@ -8,6 +8,7 @@ import { useMainStore } from '@/store';
|
||||||
import coverageStatuses from '@/constants/coverage-statuses';
|
import coverageStatuses from '@/constants/coverage-statuses';
|
||||||
import { formatAmountInDollars } from '@/helpers/text-helper.js';
|
import { formatAmountInDollars } from '@/helpers/text-helper.js';
|
||||||
import partTypeStrings from '@/constants/part-type-strings';
|
import partTypeStrings from '@/constants/part-type-strings';
|
||||||
|
import partNumberStrings from '@/constants/part-number-strings';
|
||||||
import { getHighestFullySatisfiedTier, getPackageContents } from '@/helpers/service-package-helper.js';
|
import { getHighestFullySatisfiedTier, getPackageContents } from '@/helpers/service-package-helper.js';
|
||||||
import getPriceOfLineItems from '@/helpers/price-calculator.js';
|
import getPriceOfLineItems from '@/helpers/price-calculator.js';
|
||||||
|
|
||||||
|
|
@ -141,9 +142,42 @@ describe('cart-dropdown component', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(servicePackage.exists()).toBeTruthy();
|
expect(servicePackage.exists()).toBeTruthy();
|
||||||
});
|
});
|
||||||
// TODO finish tests
|
test('non service package cart items', () => {
|
||||||
test.skip('non service package cart items', () => { });
|
// Arrange
|
||||||
test.skip('recycle cart item label when isRecycle true for some cart item', () => { });
|
const reference = '#non-packaged-cart-items';
|
||||||
|
const isExpanded = true;
|
||||||
|
const initialData = { isExpanded };
|
||||||
|
const { wrapper } = getMountedComponent({}, {}, initialData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const nonPackagedCartItems = wrapper.find(reference);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(nonPackagedCartItems.exists()).toBeTruthy();
|
||||||
|
});
|
||||||
|
test('recycle cart item label when isRecycle true for some cart item', () => {
|
||||||
|
// Arrange
|
||||||
|
const reference = '#recycle-fee-label';
|
||||||
|
const isExpanded = true;
|
||||||
|
const initialPropsData = { isExpanded };
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
supportingItems: [
|
||||||
|
{ partNumber: partNumberStrings.RECYCLE_FEE }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData, {}, initialPropsData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const recycleFeeLabel = wrapper.find(reference);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.recycleFeeCartItem).not.toBeNull();
|
||||||
|
expect(recycleFeeLabel.exists()).toBeTruthy();
|
||||||
|
});
|
||||||
test('cart footer', () => {
|
test('cart footer', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#cart-footer';
|
const reference = '#cart-footer';
|
||||||
|
|
@ -183,47 +217,6 @@ describe('cart-dropdown component', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(salesTax.exists()).toBeTruthy();
|
expect(salesTax.exists()).toBeTruthy();
|
||||||
});
|
});
|
||||||
// TODO remove
|
|
||||||
test('recycle fee when preset in supported items', () => {
|
|
||||||
// Arrange
|
|
||||||
const reference = '#recycle-fee-item';
|
|
||||||
const { wrapper } = getMountedComponent({
|
|
||||||
order: {
|
|
||||||
lineItems: {
|
|
||||||
supportingItems: [{
|
|
||||||
partNumber: partTypeStrings.RECYCLE_FEE
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const recycleFee = wrapper.find(reference);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.recycleFeeCartItem).not.toBeNull();
|
|
||||||
expect(recycleFee.exists()).toBeTruthy();
|
|
||||||
});
|
|
||||||
// TODO remove
|
|
||||||
test('mobile fee when preset', () => {
|
|
||||||
// Arrange
|
|
||||||
const reference = '#mobile-fee-item';
|
|
||||||
const { wrapper } = getMountedComponent({
|
|
||||||
order: {
|
|
||||||
lineItems: {
|
|
||||||
supportingItems: [],
|
|
||||||
mobileFee: {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const mobileFee = wrapper.find(reference);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.mobileFeeCartItem).not.toBeNull();
|
|
||||||
expect(mobileFee.exists()).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('bottom amount due', () => {
|
test('bottom amount due', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#bottom-amount-due';
|
const reference = '#bottom-amount-due';
|
||||||
|
|
@ -289,46 +282,26 @@ describe('cart-dropdown component', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(cartBasePrice.exists()).toBeFalsy();
|
expect(cartBasePrice.exists()).toBeFalsy();
|
||||||
});
|
});
|
||||||
// TODO finish test
|
test('recycle cart item label when isRecycle false for all cart items', () => {
|
||||||
test.skip('recycle cart item label when isRecycle false for all cart items', () => { });
|
|
||||||
// TODO remove
|
|
||||||
test('recycle fee when not in supported items', () => {
|
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#recycle-fee-item';
|
const reference = '#recycle-fee-label';
|
||||||
const { wrapper } = getMountedComponent({
|
const isExpanded = true;
|
||||||
|
const initialPropsData = { isExpanded };
|
||||||
|
const storeData = {
|
||||||
order: {
|
order: {
|
||||||
lineItems: {
|
lineItems: {
|
||||||
supportingItems: []
|
supportingItems: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData, {}, initialPropsData);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const recycleFee = wrapper.find(reference);
|
const recycleFeeLabel = wrapper.find(reference);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.recycleFeeCartItem).toBeNull();
|
expect(wrapper.vm.recycleFeeCartItem).toBeNull();
|
||||||
expect(recycleFee.exists()).toBeFalsy();
|
expect(recycleFeeLabel.exists()).toBeFalsy();
|
||||||
});
|
|
||||||
// TODO remove
|
|
||||||
test('mobile fee when not in supported items', () => {
|
|
||||||
// Arrange
|
|
||||||
const reference = '#mobile-fee-item';
|
|
||||||
const { wrapper } = getMountedComponent({
|
|
||||||
order: {
|
|
||||||
lineItems: {
|
|
||||||
supportingItems: [],
|
|
||||||
mobileFee: null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const mobileFee = wrapper.find(reference);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.mobileFeeCartItem).toBeNull();
|
|
||||||
expect(mobileFee.exists()).toBeFalsy();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('computed', () => {
|
describe('computed', () => {
|
||||||
|
|
@ -459,14 +432,172 @@ describe('cart-dropdown component', () => {
|
||||||
// TODO when subTotal and salesTax are finished
|
// TODO when subTotal and salesTax are finished
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe.skip('subTotal', () => {
|
describe('subTotal', () => {
|
||||||
test('when not no comp and not itac, includes deductible price', () => {});
|
test('when not no comp and not itac, includes deductible price', () => {
|
||||||
test('when no comp, includes base service price', () => {});
|
// Arrange
|
||||||
test('when ITAC, includes base service price', () => {});
|
const deductiblePrice = 872;
|
||||||
test('no issue when nonServicePackageCartItems null', () => {});
|
const baseServicePrice = 43;
|
||||||
test('when nonServicePackageCartItems non empty, sums appropriately', () => {});
|
getPriceOfLineItems.mockImplementation(() => baseServicePrice);
|
||||||
test('when deductible included, sums all prices appropriately', () => {});
|
const storeData = {
|
||||||
test('when base service price included, sums all prices appropriately', () => {});
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
isITAC: false
|
||||||
|
},
|
||||||
|
currentDeductible: deductiblePrice
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.subTotal;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(deductiblePrice);
|
||||||
|
});
|
||||||
|
test('when no comp, includes base service price', () => {
|
||||||
|
// Arrange
|
||||||
|
const deductiblePrice = 872;
|
||||||
|
const baseServicePrice = 43;
|
||||||
|
getPriceOfLineItems.mockImplementation(() => baseServicePrice);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
isITAC: false
|
||||||
|
},
|
||||||
|
currentDeductible: deductiblePrice
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.subTotal;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(baseServicePrice);
|
||||||
|
});
|
||||||
|
test('when ITAC, includes base service price', () => {
|
||||||
|
// Arrange
|
||||||
|
const deductiblePrice = 872;
|
||||||
|
const baseServicePrice = 43;
|
||||||
|
getPriceOfLineItems.mockImplementation(() => baseServicePrice);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
isITAC: true
|
||||||
|
},
|
||||||
|
currentDeductible: deductiblePrice
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.subTotal;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(baseServicePrice);
|
||||||
|
});
|
||||||
|
test('when nonServicePackageCartItems non empty, sums appropriately', () => {
|
||||||
|
// Arrange
|
||||||
|
const deductiblePrice = 0;
|
||||||
|
const subTotal = 34;
|
||||||
|
getPriceOfLineItems.mockImplementation(() => subTotal);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
isITAC: false
|
||||||
|
},
|
||||||
|
currentDeductible: deductiblePrice,
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.FRONT_WIPER
|
||||||
|
},
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.REAR_WIPER
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
const expectedPrice = 68;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.subTotal;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(expectedPrice);
|
||||||
|
});
|
||||||
|
test('when deductible included, sums all prices appropriately', () => {
|
||||||
|
// Arrange
|
||||||
|
const deductiblePrice = 54;
|
||||||
|
const subTotal = 34;
|
||||||
|
getPriceOfLineItems.mockImplementation(() => subTotal);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
isITAC: false
|
||||||
|
},
|
||||||
|
currentDeductible: deductiblePrice,
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.FRONT_WIPER
|
||||||
|
},
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.REAR_WIPER
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
const expectedPrice = 122;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.subTotal;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(expectedPrice);
|
||||||
|
});
|
||||||
|
test('when base service price included, sums all prices appropriately', () => {
|
||||||
|
// Arrange
|
||||||
|
const deductiblePrice = 54;
|
||||||
|
const subTotal = 34;
|
||||||
|
getPriceOfLineItems.mockImplementation(() => subTotal);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
isITAC: false
|
||||||
|
},
|
||||||
|
currentDeductible: deductiblePrice,
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.FRONT_WIPER
|
||||||
|
},
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.REAR_WIPER
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
const expectedPrice = 102;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.subTotal;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(expectedPrice);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe.skip('salesTax', () => {});
|
describe.skip('salesTax', () => {});
|
||||||
describe('availableLineItems', () => {
|
describe('availableLineItems', () => {
|
||||||
|
|
@ -782,17 +913,266 @@ describe('cart-dropdown component', () => {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe.skip('nonServicePackageCartItems', () => {
|
describe('nonServicePackageCartItems', () => {
|
||||||
test('when recycleFee, includes recycle fee', () => {});
|
test('when recycleFee, includes recycle fee', () => {
|
||||||
test('when mobileFee, includes mobile fee', () => {});
|
// Arrange
|
||||||
test('front wiper not included when front wiper in service package', () => {});
|
const storeData = {
|
||||||
test('rear wiper not included when rear wiper in service package', () => {});
|
order: {
|
||||||
test('rain defense not included when rain defense in service package', () => {});
|
lineItems: {
|
||||||
test('front wiper included when not in service package and in vaps', () => {});
|
supportingItems: [
|
||||||
test('rear wiper included when not in service package and in vaps', () => {});
|
{
|
||||||
test('rain defense included when not in service package and in vaps', () => {});
|
partNumber: partNumberStrings.RECYCLE_FEE
|
||||||
test('item in vaps outside front wiper, rear wiper, and rain defense never included', () => {});
|
}
|
||||||
test('returns expected when multiple variables apply', () => {});
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toContainEqual(expect.objectContaining({
|
||||||
|
isRecycle: true
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
test('when mobileFee, includes mobile fee', () => {
|
||||||
|
// Arrange
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
mobileFee: {
|
||||||
|
partType: partTypeStrings.MOBILE_FEE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.MOBILE_FEE
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
test('front wiper not included when front wiper in service package', () => {
|
||||||
|
// Arrange
|
||||||
|
getPriceOfLineItems.mockImplementation(() => 123);
|
||||||
|
getPackageContents.mockImplementationOnce(() => [partTypeStrings.FRONT_WIPER]);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.FRONT_WIPER
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).not.toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.FRONT_WIPER
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
test('rear wiper not included when rear wiper in service package', () => {
|
||||||
|
// Arrange
|
||||||
|
getPriceOfLineItems.mockImplementation(() => 123);
|
||||||
|
getPackageContents.mockImplementationOnce(() => [partTypeStrings.REAR_WIPER]);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.REAR_WIPER
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).not.toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.REAR_WIPER
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
test('rain defense not included when rain defense in service package', () => {
|
||||||
|
// Arrange
|
||||||
|
getPriceOfLineItems.mockImplementation(() => 123);
|
||||||
|
getPackageContents.mockImplementationOnce(() => [partTypeStrings.RAIN_DEFENSE]);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.RAIN_DEFENSE
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).not.toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.RAIN_DEFENSE
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
test('front wiper included when not in service package and in vaps', () => {
|
||||||
|
// Arrange
|
||||||
|
getPriceOfLineItems.mockImplementation(() => 123);
|
||||||
|
getPackageContents.mockImplementationOnce(() => []);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.FRONT_WIPER
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.FRONT_WIPER
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
test('rear wiper included when not in service package and in vaps', () => {
|
||||||
|
// Arrange
|
||||||
|
getPriceOfLineItems.mockImplementation(() => 123);
|
||||||
|
getPackageContents.mockImplementationOnce(() => []);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.REAR_WIPER
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.REAR_WIPER
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
test('rain defense included when not in service package and in vaps', () => {
|
||||||
|
// Arrange
|
||||||
|
getPriceOfLineItems.mockImplementation(() => 123);
|
||||||
|
getPackageContents.mockImplementationOnce(() => []);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.RAIN_DEFENSE
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.RAIN_DEFENSE
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
test('item in vaps outside front wiper, rear wiper, and rain defense never included', () => {
|
||||||
|
// Arrange
|
||||||
|
getPriceOfLineItems.mockImplementation(() => 123);
|
||||||
|
getPackageContents.mockImplementationOnce(() => []);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.RECALIBRATION
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).not.toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.RECALIBRATION
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
test('returns expected when multiple variables apply', () => {
|
||||||
|
// Arrange
|
||||||
|
getPriceOfLineItems.mockImplementation(() => 123);
|
||||||
|
getPackageContents.mockImplementationOnce(() => [partTypeStrings.FRONT_WIPER]);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
supportingItems: [
|
||||||
|
{
|
||||||
|
partNumber: partNumberStrings.RECYCLE_FEE
|
||||||
|
}
|
||||||
|
],
|
||||||
|
mobileFee: {
|
||||||
|
partType: partTypeStrings.MOBILE_FEE
|
||||||
|
},
|
||||||
|
vaps: [
|
||||||
|
{ partType: partTypeStrings.RECALIBRATION },
|
||||||
|
{ partType: partTypeStrings.FRONT_WIPER },
|
||||||
|
{ partType: partTypeStrings.REAR_WIPER }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.nonServicePackageCartItems;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result.length).toBe(3);
|
||||||
|
expect(result).toContainEqual(expect.objectContaining({
|
||||||
|
isRecycle: true
|
||||||
|
}));
|
||||||
|
expect(result).toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.MOBILE_FEE
|
||||||
|
}));
|
||||||
|
expect(result).toContainEqual(expect.objectContaining({
|
||||||
|
partType: partTypeStrings.REAR_WIPER
|
||||||
|
}));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('servicePackageLabelWidget', () => {
|
describe('servicePackageLabelWidget', () => {
|
||||||
test.each([
|
test.each([
|
||||||
|
|
@ -941,7 +1321,7 @@ describe('cart-dropdown component', () => {
|
||||||
const storeData = {
|
const storeData = {
|
||||||
order: {
|
order: {
|
||||||
lineItems: {
|
lineItems: {
|
||||||
supportingItems: [{ partNumber: partTypeStrings.RECYCLE_FEE }]
|
supportingItems: [{ partNumber: partNumberStrings.RECYCLE_FEE }]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1016,13 +1396,90 @@ describe('cart-dropdown component', () => {
|
||||||
expect(result.name).toBe(expectedName);
|
expect(result.name).toBe(expectedName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe.only('packagePrice', () => {
|
describe('packagePrice', () => {
|
||||||
test('returns 0 when servicePackageCartItems is null', () => {
|
test('returns 0 when servicePackageCartItems is empty', () => {
|
||||||
|
// Arrange
|
||||||
|
getPriceOfLineItems.mockImplementation(() => 123);
|
||||||
|
getPackageContents.mockImplementationOnce(() => []);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{
|
||||||
|
partType: partTypeStrings.REAR_WIPER
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.packagePrice;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(0);
|
||||||
|
});
|
||||||
|
test('returns expected when servicePackageCartItems not empty', () => {
|
||||||
|
// Arrange
|
||||||
|
const rearPrice = 101;
|
||||||
|
const frontPrice = 9;
|
||||||
|
getPriceOfLineItems.mockImplementation((lineItems) => {
|
||||||
|
if (lineItems.some((item) => item.partType === partTypeStrings.FRONT_WIPER)) {
|
||||||
|
return frontPrice;
|
||||||
|
}
|
||||||
|
if (lineItems.some((item) => item.partType === partTypeStrings.REAR_WIPER)) {
|
||||||
|
return rearPrice;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
getPackageContents.mockImplementationOnce(() => [partTypeStrings.FRONT_WIPER, partTypeStrings.REAR_WIPER]);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{ partType: partTypeStrings.FRONT_WIPER },
|
||||||
|
{ partType: partTypeStrings.REAR_WIPER }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
const expectedPrice = 110;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.packagePrice;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(expectedPrice);
|
||||||
|
});
|
||||||
|
test('returns expected when servicePackageCartItems has one item', () => {
|
||||||
|
// Arrange
|
||||||
|
const frontPrice = 9;
|
||||||
|
getPriceOfLineItems.mockImplementation((lineItems) => {
|
||||||
|
if (lineItems.some((item) => item.partType === partTypeStrings.FRONT_WIPER)) {
|
||||||
|
return frontPrice;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
getPackageContents.mockImplementationOnce(() => [partTypeStrings.FRONT_WIPER, partTypeStrings.REAR_WIPER]);
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
vaps: [
|
||||||
|
{ partType: partTypeStrings.FRONT_WIPER }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.packagePrice;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(frontPrice);
|
||||||
});
|
});
|
||||||
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', () => {
|
||||||
|
|
@ -1031,12 +1488,8 @@ describe('cart-dropdown component', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const storeData = {
|
const storeData = {
|
||||||
order: {
|
order: {
|
||||||
payment: {
|
|
||||||
insuranceCoverage: {
|
|
||||||
coverageStatus: coverageStatuses.VERIFIED
|
|
||||||
}
|
|
||||||
},
|
|
||||||
policy: {
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
isITAC: false
|
isITAC: false
|
||||||
},
|
},
|
||||||
currentDeductible: null
|
currentDeductible: null
|
||||||
|
|
@ -1055,12 +1508,8 @@ describe('cart-dropdown component', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const storeData = {
|
const storeData = {
|
||||||
order: {
|
order: {
|
||||||
payment: {
|
|
||||||
insuranceCoverage: {
|
|
||||||
coverageStatus: coverageStatuses.PENDING
|
|
||||||
}
|
|
||||||
},
|
|
||||||
policy: {
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
isITAC: false
|
isITAC: false
|
||||||
},
|
},
|
||||||
currentDeductible: 321
|
currentDeductible: 321
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ export default {
|
||||||
...(otherParts ?? [])
|
...(otherParts ?? [])
|
||||||
],
|
],
|
||||||
deductible: currentDeductible,
|
deductible: currentDeductible,
|
||||||
isExpanded: true, // false,
|
isExpanded: false,
|
||||||
widget: {
|
widget: {
|
||||||
amountDue: 'AmountDueTextWidget',
|
amountDue: 'AmountDueTextWidget',
|
||||||
deductible: 'DeductibleWidget',
|
deductible: 'DeductibleWidget',
|
||||||
|
|
@ -204,7 +204,7 @@ export default {
|
||||||
return !useMainStore().isNoComp && !useMainStore().policy.isITAC;
|
return !useMainStore().isNoComp && !useMainStore().policy.isITAC;
|
||||||
},
|
},
|
||||||
baseServicePrice() {
|
baseServicePrice() {
|
||||||
return getPriceOfLineItems(this.baseServiceLineItems);
|
return getPriceOfLineItems(this.baseServiceLineItems) ?? 0;
|
||||||
},
|
},
|
||||||
isUnverified() {
|
isUnverified() {
|
||||||
return !useMainStore().isNoComp && !useMainStore().policy.isITAC
|
return !useMainStore().isNoComp && !useMainStore().policy.isITAC
|
||||||
|
|
@ -215,7 +215,7 @@ export default {
|
||||||
? 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
|
||||||
) ?? 0;
|
) ?? 0;
|
||||||
return basePrice + nonPackageCartItemsPrice + this.packagePrice;
|
return basePrice + nonPackageCartItemsPrice + this.packagePrice;
|
||||||
|
|
@ -310,7 +310,7 @@ export default {
|
||||||
},
|
},
|
||||||
packagePrice() {
|
packagePrice() {
|
||||||
return this.servicePackageCartItems?.reduce(
|
return this.servicePackageCartItems?.reduce(
|
||||||
(accumulator, cartItem) => accumulator + cartItem.subTotal,
|
(accumulator, cartItem) => accumulator + (cartItem?.subTotal ?? 0),
|
||||||
0
|
0
|
||||||
) ?? 0;
|
) ?? 0;
|
||||||
},
|
},
|
||||||
|
|
@ -382,8 +382,8 @@ export default {
|
||||||
getDisplayed(amount, canBeVerifyingCoverage = true) {
|
getDisplayed(amount, canBeVerifyingCoverage = true) {
|
||||||
return canBeVerifyingCoverage
|
return canBeVerifyingCoverage
|
||||||
&& this.isUnverified
|
&& this.isUnverified
|
||||||
&& !this.isNoComp
|
&& !useMainStore().isNoComp
|
||||||
&& !this.isITAC
|
&& !useMainStore().policy.isITAC
|
||||||
? VERIFYING_COVERAGE
|
? VERIFYING_COVERAGE
|
||||||
: formatAmountInDollars(amount);
|
: formatAmountInDollars(amount);
|
||||||
},
|
},
|
||||||
|
|
@ -410,7 +410,7 @@ export default {
|
||||||
getCartItemForVapsPart(partType) {
|
getCartItemForVapsPart(partType) {
|
||||||
const label = this.getCmsContentForVapsType(partType);
|
const label = this.getCmsContentForVapsType(partType);
|
||||||
const lineItems = this.vapsInOrder
|
const lineItems = this.vapsInOrder
|
||||||
?.filter((vapsLineItem) => vapsLineItem.partType === partType);
|
?.filter((vapsLineItem) => vapsLineItem.partType === partType) ?? [];
|
||||||
return this.getCartItem(label, lineItems, true, partType, true, false);
|
return this.getCartItem(label, lineItems, true, partType, true, false);
|
||||||
},
|
},
|
||||||
removeItem(partType, isVap) {
|
removeItem(partType, isVap) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue