Add remove tests
This commit is contained in:
parent
799318b02b
commit
5ccd00329f
2 changed files with 82 additions and 15 deletions
|
|
@ -141,8 +141,9 @@ describe('cart-dropdown component', () => {
|
|||
// Assert
|
||||
expect(servicePackage.exists()).toBeTruthy();
|
||||
});
|
||||
test.todo('non service package cart items', () => { });
|
||||
test.todo('recycle cart item label when isRecycle true for some cart item', () => { });
|
||||
// TODO finish tests
|
||||
test.skip('non service package cart items', () => { });
|
||||
test.skip('recycle cart item label when isRecycle true for some cart item', () => { });
|
||||
test('cart footer', () => {
|
||||
// Arrange
|
||||
const reference = '#cart-footer';
|
||||
|
|
@ -288,7 +289,8 @@ describe('cart-dropdown component', () => {
|
|||
// Assert
|
||||
expect(cartBasePrice.exists()).toBeFalsy();
|
||||
});
|
||||
test.todo('recycle cart item label when isRecycle false for all cart items', () => { });
|
||||
// TODO finish test
|
||||
test.skip('recycle cart item label when isRecycle false for all cart items', () => { });
|
||||
// TODO remove
|
||||
test('recycle fee when not in supported items', () => {
|
||||
// Arrange
|
||||
|
|
@ -457,7 +459,7 @@ describe('cart-dropdown component', () => {
|
|||
// TODO when subTotal and salesTax are finished
|
||||
});
|
||||
});
|
||||
describe.todo('subTotal', () => {
|
||||
describe.skip('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', () => {});
|
||||
|
|
@ -466,7 +468,7 @@ describe('cart-dropdown component', () => {
|
|||
test('when deductible included, sums all prices appropriately', () => {});
|
||||
test('when base service price included, sums all prices appropriately', () => {});
|
||||
});
|
||||
describe.todo('salesTax', () => {});
|
||||
describe.skip('salesTax', () => {});
|
||||
describe('availableLineItems', () => {
|
||||
test('returns expected when glassParts null', async () => {
|
||||
// Arrange
|
||||
|
|
@ -780,7 +782,7 @@ describe('cart-dropdown component', () => {
|
|||
}));
|
||||
});
|
||||
});
|
||||
describe.todo('nonServicePackageCartItems', () => {
|
||||
describe.skip('nonServicePackageCartItems', () => {
|
||||
test('when recycleFee, includes recycle fee', () => {});
|
||||
test('when mobileFee, includes mobile fee', () => {});
|
||||
test('front wiper not included when front wiper in service package', () => {});
|
||||
|
|
@ -1014,8 +1016,10 @@ describe('cart-dropdown component', () => {
|
|||
expect(result.name).toBe(expectedName);
|
||||
});
|
||||
});
|
||||
describe.todo('packagePrice', () => {
|
||||
test('returns 0 when servicePackageCartItems is null', () => {});
|
||||
describe.only('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', () => {});
|
||||
|
|
@ -1376,12 +1380,75 @@ describe('cart-dropdown component', () => {
|
|||
expect(result.subTotal).toBe(expectedSubtotal);
|
||||
});
|
||||
});
|
||||
describe.todo('removeItem', () => {
|
||||
describe('removeItem', () => {
|
||||
test('when isVap false, updateVaps not called', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
mobileFee: { partType: partTypeStrings.MOBILE_FEE },
|
||||
vaps: [
|
||||
{ partType: partTypeStrings.FRONT_WIPER },
|
||||
{ partType: partTypeStrings.RAIN_DEFENSE }
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const initialVapsInOrder = wrapper.vm.vapsInOrder;
|
||||
const partType = partTypeStrings.RAIN_DEFENSE;
|
||||
const isVap = false;
|
||||
|
||||
// Act
|
||||
wrapper.vm.removeItem(partType, isVap);
|
||||
|
||||
// Assert
|
||||
expect(useMainStore().updateVaps).not.toHaveBeenCalled();
|
||||
expect(wrapper.vm.vapsInOrder).toStrictEqual(initialVapsInOrder);
|
||||
});
|
||||
test('when isVap true, vapsInOrder is expected and updateVaps called', async () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
mobileFee: { partType: partTypeStrings.MOBILE_FEE },
|
||||
vaps: [
|
||||
{ partType: partTypeStrings.FRONT_WIPER },
|
||||
{ partType: partTypeStrings.REAR_WIPER }
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const partType = partTypeStrings.FRONT_WIPER;
|
||||
const isVap = true;
|
||||
const expectedVaps = [{ partType: partTypeStrings.REAR_WIPER }];
|
||||
|
||||
// Act
|
||||
wrapper.vm.removeItem(partType, isVap);
|
||||
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(useMainStore().updateVaps).toHaveBeenCalled();
|
||||
expect(wrapper.vm.vapsInOrder).toStrictEqual(expectedVaps);
|
||||
});
|
||||
test('when isVap true and vapsInOrder null, vapsInOrder becomes []', () => {
|
||||
// Arrange
|
||||
const computedData = {
|
||||
vapsInOrder: null
|
||||
};
|
||||
const { wrapper } = getMountedComponent({}, computedData);
|
||||
const partType = partTypeStrings.FRONT_WIPER;
|
||||
const isVap = true;
|
||||
|
||||
// Act
|
||||
wrapper.vm.removeItem(partType, isVap);
|
||||
|
||||
// Assert
|
||||
expect(useMainStore().updateVaps).toHaveBeenCalled();
|
||||
expect(wrapper.vm.vapsInOrder).toStrictEqual([]);
|
||||
});
|
||||
test('when isVap true, vapsInOrder is expected', () => {});
|
||||
test('when isVap true and vapsInOrder null, vapsInOrder becomes []', () => {});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ export default {
|
|||
return items;
|
||||
},
|
||||
nonServicePackageCartItems() {
|
||||
const partTypesInOrder = this.vapsInOrder.reduce(
|
||||
const partTypesInOrder = this.vapsInOrder?.reduce(
|
||||
(accumulator, vap) => {
|
||||
if (!accumulator.includes(vap.partType)) {
|
||||
accumulator.push(vap.partType);
|
||||
|
|
@ -274,7 +274,7 @@ export default {
|
|||
return accumulator;
|
||||
},
|
||||
[]
|
||||
);
|
||||
) ?? [];
|
||||
const partTypesInOrderButNotPackage = partTypesInOrder
|
||||
.filter((partType) => !this.partTypesInServicePackage.includes(partType))
|
||||
?? [];
|
||||
|
|
@ -395,10 +395,10 @@ export default {
|
|||
name: label,
|
||||
partType,
|
||||
subTotal: getPriceOfLineItems(lineItems),
|
||||
salesTax: lineItems.reduce(
|
||||
salesTax: lineItems?.reduce(
|
||||
(accumulator, lineItem) => accumulator + lineItem.salesTax,
|
||||
0
|
||||
),
|
||||
) ?? 0,
|
||||
isRemovable,
|
||||
isVap,
|
||||
isRecycle
|
||||
|
|
|
|||
Loading…
Reference in a new issue