Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/counter-assignment.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions src/tests/Counter.test.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
// import necessary react testing library helpers here
// import the Counter component here
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Counter from '../components/Counter';

beforeEach(() => {
// Render the Counter component here
})
render(<Counter />);
});

test('renders counter message', () => {
// Complete the unit test below based on the objective in the line above
const counterMessage = screen.getByText(/Counter/i);
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 counterValue = screen.getByTestId('count');
expect(counterValue).toHaveTextContent('0');
});

test('clicking + increments the count', () => {
// Complete the unit test below based on the objective in the line above
const incrementButton = screen.getByRole('button', { name: /\+/i });
userEvent.click(incrementButton);
const counterValue = screen.getByTestId('count');
expect(counterValue).toHaveTextContent('1');
});

test('clicking - decrements the count', () => {
// Complete the unit test below based on the objective in the line above
const decrementButton = screen.getByRole('button', { name: /-/i });
userEvent.click(decrementButton);
const counterValue = screen.getByTestId('count');
expect(counterValue).toHaveTextContent('-1');
});