Skip to content

Commit

Permalink
Adds testing for useCheckoutPricing#adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrudner committed Jan 29, 2020
1 parent 4d67b2f commit 8544db1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/use-checkout-pricing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const mockPricing = {
};

const checkoutPricingReturn = {
adjustment: jest.fn(() => checkoutPricingReturn),
subscription: jest.fn(() => checkoutPricingReturn),
catch: jest.fn(() => mockPricing),
then: jest.fn(() => checkoutPricingReturn),
Expand Down Expand Up @@ -153,4 +154,20 @@ describe('useCheckoutPricing', function() {
expect(queryByText('loading')).not.toBeInTheDocument();
});
});

it('should handle adjustments', async () => {
checkoutPricingReturn.catch = jest.fn(() => checkoutPricingReturn);

const initialInput = { adjustments: [{ itemCode: 'basic', quantity: 2, currency: 'usd' }] };

render(<CheckoutPricingFixture initialInput={initialInput} />);

await wait(() => {
expect(checkoutPricingReturn.adjustment).toHaveBeenCalledWith({
currency: 'usd',
itemCode: 'basic',
quantity: 2,
});
});
});
});

0 comments on commit 8544db1

Please sign in to comment.