From dc318c10eea717a835407bb86efb5c8e52780d04 Mon Sep 17 00:00:00 2001 From: Steve Kinney Date: Mon, 30 Sep 2024 10:57:35 -0600 Subject: [PATCH] Remove answers from the accident counter --- .../accident-counter/src/counter.test.jsx | 78 ++++--------------- 1 file changed, 17 insertions(+), 61 deletions(-) diff --git a/examples/accident-counter/src/counter.test.jsx b/examples/accident-counter/src/counter.test.jsx index 09655c7..e7b9472 100644 --- a/examples/accident-counter/src/counter.test.jsx +++ b/examples/accident-counter/src/counter.test.jsx @@ -1,10 +1,11 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; + import { Counter } from './counter'; import '@testing-library/jest-dom'; -describe('Counter Component', () => { +describe('Counter ', () => { beforeEach(() => { render(); }); @@ -14,72 +15,27 @@ describe('Counter Component', () => { expect(countElement).toHaveTextContent('0'); }); - it('displays "days" when the count is 0', () => { - const unitElement = screen.getByTestId('counter-unit'); - expect(unitElement).toHaveTextContent('days'); - }); - - it('increments the count when the "Increment" button is clicked', async () => { - const incrementButton = screen.getByText('Increment'); - await userEvent.click(incrementButton); // Using userEvent for a real click event - - const countElement = screen.getByTestId('counter-count'); - expect(countElement).toHaveTextContent('1'); - }); - - it('displays "day" when the count is 1', async () => { - const incrementButton = screen.getByText('Increment'); - await userEvent.click(incrementButton); // Increment the count - - const unitElement = screen.getByTestId('counter-unit'); - expect(unitElement).toHaveTextContent('day'); - }); - - it('decrements the count when the "Decrement" button is clicked', async () => { - const incrementButton = screen.getByText('Increment'); - const decrementButton = screen.getByText('Decrement'); - - await userEvent.click(incrementButton); // Increment first - await userEvent.click(decrementButton); // Then decrement - - const countElement = screen.getByTestId('counter-count'); - expect(countElement).toHaveTextContent('0'); - }); - - it('does not allow decrementing below 0', async () => { - const decrementButton = screen.getByText('Decrement'); - await userEvent.click(decrementButton); // Should not decrement below 0 - - const countElement = screen.getByTestId('counter-count'); - expect(countElement).toHaveTextContent('0'); - }); - - it('resets the count when the "Reset" button is clicked', async () => { - const incrementButton = screen.getByText('Increment'); - const resetButton = screen.getByText('Reset'); - - await userEvent.click(incrementButton); // Increment first - await userEvent.click(resetButton); // Then reset - - const countElement = screen.getByTestId('counter-count'); - expect(countElement).toHaveTextContent('0'); - }); - it('disables the "Decrement" and "Reset" buttons when the count is 0', () => { - const decrementButton = screen.getByText('Decrement'); - const resetButton = screen.getByText('Reset'); + const decrementButton = screen.getByRole('button', { name: 'Decrement' }); + const resetButton = screen.getByRole('button', { name: 'Reset' }); expect(decrementButton).toBeDisabled(); expect(resetButton).toBeDisabled(); }); - it('updates the document title based on the count', async () => { - const incrementButton = screen.getByText('Increment'); - await userEvent.click(incrementButton); + it.todo('displays "days" when the count is 0', () => {}); - expect(document.title).toBe('1 day'); + it.todo('increments the count when the "Increment" button is clicked', async () => {}); - await userEvent.click(incrementButton); - expect(document.title).toBe('2 days'); - }); + it.todo('displays "day" when the count is 1', async () => {}); + + it.todo('decrements the count when the "Decrement" button is clicked', async () => {}); + + it.todo('does not allow decrementing below 0', async () => {}); + + it.todo('resets the count when the "Reset" button is clicked', async () => {}); + + it.todo('disables the "Decrement" and "Reset" buttons when the count is 0', () => {}); + + it.todo('updates the document title based on the count', async () => {}); });