Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,29 @@ describe('HomePage component', () => {
);
const productContainers = await screen.findAllByTestId('product-container');

const quantitySelector1 = within(productContainers[0])
.getByTestId('product-quantity-selector');
await user.selectOptions(quantitySelector1, '2');

const addToCartButton1 = within(productContainers[0])
.getByTestId('add-to-cart-button');
await user.click(addToCartButton1);

const quantitySelector2 = within(productContainers[1])
.getByTestId('product-quantity-selector');
await user.selectOptions(quantitySelector2, '3');

const addToCartButton2 = within(productContainers[1])
.getByTestId('add-to-cart-button');
await user.click(addToCartButton2);

expect(axios.post).toHaveBeenNthCalledWith(1, '/api/cart-items', {
productId: 'e43638ce-6aa0-4b85-b27f-e1d07eb678c6',
quantity: 1
quantity: 2
});
expect(axios.post).toHaveBeenNthCalledWith(2, '/api/cart-items', {
productId: '15b6fc6f-327a-4ec4-896f-486349e85a3d',
quantity: 1
quantity: 3
});
expect(loadCart).toHaveBeenCalledTimes(2);
});
Expand Down