Testing
See original GitHub issueTesting library is already set up, just need to do the things
Things to test:
- Skus maintains this shape
{
sku_abc123: 1,
sku_xyz456: 4,
}
This is the source of truth formatCheckoutData. When addItems is fired, the related sku ID updates the quantity (the number next to it)
- Checkout data is formatted to maintain this shape:
[
{
sku: 'sku_abc123',
quantity: 1
}
]
The function formatCheckoutCart is what handles this.This might mean writing tests for formatCheckoutCart as well, which actually relies on the skus object
-
Delete Item deletes specific item from
cart.skus
-
Store last clicked Stores the value of the last clicked item (saves skuID)
-
redirectToCheckout gets the required data to go to Stripe’s checkout experience. The items array, successUrl after successful purchase and cancelUrl for cancelled payments.
-
Handle quantity change handles updating the skus object after an item is added or removed via updateQuantity function. If the quantity drops to 0 or if quantity doesn’t exist, the sku is removed from the skus object
-
toggleRightMenu should be refactored to something like, “shouldDisplayCart” or something. This would be a boolean
-
Total Price totals up all prices of all products properly
Issue Analytics
- State:
- Created 4 years ago
- Comments:39 (36 by maintainers)
Top GitHub Comments
@ChrisBrownie55 I think this could be closed, I think we have full test coverage, yeah? We might as well just include tests as part of feature releases. Good work everyone!!!
Totally agree, I really appreciate your help!