Last active
August 12, 2022 05:56
-
-
Save nottyo/c3de28dce1eb9fb3cc1fa7f4f9d0681d to your computer and use it in GitHub Desktop.
RTL Practice - Parent.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { render, screen } from '@testing-library/react'; | |
| import userEvent from '@testing-library/user-event'; | |
| import Parent from './Parent'; | |
| describe('Parent Integration Test', () => { | |
| it('emit click increased event from child component', () => { | |
| // when | |
| render(<Parent />); | |
| const increaseButton = screen.getByTestId('increase-click'); | |
| userEvent.click(increaseButton); | |
| // then | |
| const counter = screen.getByTestId('counter'); | |
| expect(counter).toHaveTextContent('1'); | |
| }); | |
| it('emit click decreased event from child component', () => { | |
| // when | |
| render(<Parent />); | |
| const increaseButton = screen.getByTestId('increase-click'); | |
| userEvent.click(increaseButton); | |
| const decreaseButton = screen.getByTestId('decrease-click'); | |
| userEvent.click(decreaseButton); | |
| // then | |
| const counter = screen.getByTestId('counter'); | |
| expect(counter).toHaveTextContent('0'); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment