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 numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ vi.mock('axios');
describe('Product component', () => {
let product;
let loadCart;
let user;

beforeEach(() => {
product = {
Expand All@@ -24,6 +25,7 @@ describe('Product component', () => {
};

loadCart = vi.fn();
user = userEvent.setup();
});

it('displays the product details correctly', () => {
Expand DownExpand Up@@ -53,7 +55,6 @@ describe('Product component', () => {
it('adds a product to the cart', async () => {
render(<Product product={product} loadCart={loadCart} />);

const user = userEvent.setup();
const addToCartButton = screen.getByTestId('add-to-cart-button');
await user.click(addToCartButton);

Expand All@@ -73,7 +74,6 @@ describe('Product component', () => {
const quantitySelector = screen.getByTestId('product-quantity-selector');
expect(quantitySelector).toHaveValue('1');

const user = userEvent.setup();
await user.selectOptions(quantitySelector, '3');
expect(quantitySelector).toHaveValue('3');

Expand Down