diff --git a/src/tests/Counter.test.js b/src/tests/Counter.test.js index 36cc18aa..8f1c412c 100644 --- a/src/tests/Counter.test.js +++ b/src/tests/Counter.test.js @@ -1,22 +1,39 @@ // import necessary react testing library helpers here +import React from 'react'; +import { render, fireEvent, screen } from '@testing-library/react'; + // import the Counter component here +import Counter from "../components/Counter"; beforeEach(() => { // Render the Counter component here + render(); }) test('renders counter message', () => { // Complete the unit test below based on the objective in the line above + const counterMessage = screen.getByText('Counter'); + expect(counterMessage).toBeInTheDocument(); }); test('should render initial count with value of 0', () => { // Complete the unit test below based on the objective in the line above + const initialCount = screen.getByTestId('count'); + expect(initialCount).toHaveTextContent('0'); }); test('clicking + increments the count', () => { // Complete the unit test below based on the objective in the line above + const incrementButton = screen.getByText('+'); + const initialCount = screen.getByTestId('count'); + fireEvent.click(incrementButton); + expect(initialCount).toHaveTextContent('1'); }); test('clicking - decrements the count', () => { // Complete the unit test below based on the objective in the line above + const decrementButton = screen.getByText('-'); + const initialCount = screen.getByTestId('count'); + fireEvent.click(decrementButton); + expect(initialCount).toHaveTextContent('-1'); });