From 1fb62e636f20ca7db71faa157c376fe4890cce51 Mon Sep 17 00:00:00 2001 From: Spencer Lochne Date: Sun, 11 May 2025 00:35:27 -0400 Subject: [PATCH] 9h Solution --- .../src/pages/home/HomePage.test.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/2-copy-of-code/lesson-09/ecommerce-project/src/pages/home/HomePage.test.jsx b/2-copy-of-code/lesson-09/ecommerce-project/src/pages/home/HomePage.test.jsx index 41507ea..19b6a02 100755 --- a/2-copy-of-code/lesson-09/ecommerce-project/src/pages/home/HomePage.test.jsx +++ b/2-copy-of-code/lesson-09/ecommerce-project/src/pages/home/HomePage.test.jsx @@ -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); });