diff --git a/npm-run-test.png b/npm-run-test.png new file mode 100644 index 00000000..b061d78a Binary files /dev/null and b/npm-run-test.png differ diff --git a/src/tests/Counter.test.js b/src/tests/Counter.test.js index 36cc18aa..fb2eb51f 100644 --- a/src/tests/Counter.test.js +++ b/src/tests/Counter.test.js @@ -1,22 +1,34 @@ // import necessary react testing library helpers here // import the Counter component here +import { render, screen, fireEvent } from '@testing-library/react'; +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 + expect(screen.getByRole('heading')).toHaveTextContent('Counter'); }); test('should render initial count with value of 0', () => { // Complete the unit test below based on the objective in the line above + const count = screen.getByTestId('count'); + expect(count).toHaveTextContent(0); }); test('clicking + increments the count', () => { // Complete the unit test below based on the objective in the line above + fireEvent.click(screen.getByText('+')); + const count = screen.getByTestId('count'); + expect(count).toHaveTextContent(1); }); test('clicking - decrements the count', () => { // Complete the unit test below based on the objective in the line above + fireEvent.click(screen.getByText('-')); + const count = screen.getByTestId('count'); + expect(count).toHaveTextContent(-1); });