question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing 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:closed
  • Created 4 years ago
  • Comments:39 (36 by maintainers)

github_iconTop GitHub Comments

2reactions
dayhaysooscommented, Apr 12, 2020

@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!!!

1reaction
dayhaysooscommented, Mar 29, 2020

Also, I believe that in the above code for redirectToCheckout, the error object should be returned so that the developer can handle notifying their user that an error occurred instead of simply logging it where the average user won’t know to check.

Totally agree, I really appreciate your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

COVID-19 Testing: What You Need to Know - CDC
Viral tests look for a current infection with SARS-CoV-2, the virus that causes COVID-19, by testing specimens from your nose or mouth. There...
Read more >
Community-Based Testing Sites for COVID-19 - HHS.gov
Find Testing Resources in Your State. COVID-19 tests are available to everyone in the U.S., including the uninsured. Select your state below to...
Read more >
Testing.com: Order Lab Tests and Blood Tests Online
Hundreds of easy-to-read lab testing guides. Confidential, secure and convenient online lab test ordering powered by trusted physician networks. Compassionate ...
Read more >
Get free at-⁠home COVID-⁠19 tests this winter
15,000+ Free Testing Sites. No-cost antigen and PCR COVID-⁠19 tests are available to everyone in the U.S., including the uninsured, at more than...
Read more >
Find COVID-19 Tests
Find COVID-19 tests near you. Four ways to get tested: free community events or fixed test sites in NC, your medical provider or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found