Skip to content

Commit b79104a

Browse files
GpxKent C. Dodds
authored and
Kent C. Dodds
committed
docs: ✏️ fix "handle submit" test and add expectation (#186)
<!-- Thanks for your interest in the project. Bugs filed and PRs submitted are appreciated! Please make sure that you are familiar with and follow the Code of Conduct for this project (found in the CODE_OF_CONDUCT.md file). Also, please make sure you're familiar with and follow the instructions in the contributing guidelines (found in the CONTRIBUTING.md file). If you're new to contributing to open source projects, you might find this free video course helpful: http://kcd.im/pull-request Please fill out the information below to expedite the review and (hopefully) merge of your pull request! --> <!-- What changes are being made? (What feature/bug is being fixed here?) --> **What**: The "clicks submit button" test was not working because it was missing `handleClick`. Also, it did not have any expectation which is weird for a test. <!-- Why are these changes necessary? --> **Why**: I think having the test more "real-worldly" will make it easier to understand. <!-- How were these changes implemented? --> **How**: <!-- Have you done all of these things? --> **Checklist**: <!-- add "N/A" to the end of each line that's irrelevant to your changes --> <!-- to check an item, place an "x" in the box like so: "- [x] Documentation" --> - [x] Documentation - [ ] Tests N/A - [X] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? --> - [ ] Added myself to contributors table N/A <!-- this is optional, see the contributing guidelines for instructions --> <!-- feel free to add additional comments -->
1 parent 9c8c933 commit b79104a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,11 @@ import {render, cleanup, fireEvent} from 'react-testing-library'
607607
afterEach(cleanup)
608608

609609
test('clicks submit button', () => {
610+
const handleClick = jest.fn()
610611
const {getByText} = render(<button onClick={handleClick}>Submit</button>)
611612

612613
fireEvent.click(getByText('Submit'))
614+
expect(handleClick).toHaveBeenCalledTimes(1)
613615
})
614616
```
615617

0 commit comments

Comments
 (0)