Skip to content

Commit 54c20a3

Browse files
committed
Add a definition for TextMatch and replace the query helper arguments with it.
docs: remove unnecessary variable in the fireEvent documentation (#51)
1 parent f671b69 commit 54c20a3

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

.all-contributorsrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,26 @@
167167
"contributions": [
168168
"doc"
169169
]
170+
},
171+
{
172+
"login": "thchia",
173+
"name": "Thomas Chia",
174+
"avatar_url": "https://avatars2.githubusercontent.com/u/21194045?v=4",
175+
"profile": "https://github.com/thchia",
176+
"contributions": [
177+
"code",
178+
"infra",
179+
"tool"
180+
]
181+
},
182+
{
183+
"login": "thiagopaiva99",
184+
"name": "Thiago Galvani",
185+
"avatar_url": "https://avatars3.githubusercontent.com/u/20430611?v=4",
186+
"profile": "http://ilegra.com/",
187+
"contributions": [
188+
"doc"
189+
]
170190
}
171191
]
172192
}

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[![downloads][downloads-badge]][npmtrends]
1717
[![MIT License][license-badge]][license]
1818

19-
[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors)
19+
[![All Contributors](https://img.shields.io/badge/all_contributors-18-orange.svg?style=flat-square)](#contributors)
2020
[![PRs Welcome][prs-badge]][prs]
2121
[![Code of Conduct][coc-badge]][coc]
2222

@@ -374,9 +374,7 @@ afterEach(cleanup)
374374
375375
test('clicks submit button', () => {
376376
const spy = jest.fn()
377-
const {unmount, getByText} = renderIntoDocument(
378-
<button onClick={spy}>Submit</button>,
379-
)
377+
const {getByText} = renderIntoDocument(<button onClick={spy}>Submit</button>)
380378
381379
fireEvent(
382380
getByText('Submit'),
@@ -726,13 +724,11 @@ light-weight, simple, and understandable.
726724
Thanks goes to these people ([emoji key][emojis]):
727725

728726
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
729-
730727
<!-- prettier-ignore -->
731728
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub><b>Kent C. Dodds</b></sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=kentcdodds "Code") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=kentcdodds "Documentation") [🚇](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=kentcdodds "Tests") | [<img src="https://avatars1.githubusercontent.com/u/2430381?v=4" width="100px;"/><br /><sub><b>Ryan Castner</b></sub>](http://audiolion.github.io)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=audiolion "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/8008023?v=4" width="100px;"/><br /><sub><b>Daniel Sandiego</b></sub>](https://www.dnlsandiego.com)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=dnlsandiego "Code") | [<img src="https://avatars2.githubusercontent.com/u/12592677?v=4" width="100px;"/><br /><sub><b>Paweł Mikołajczyk</b></sub>](https://github.com/Miklet)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=Miklet "Code") | [<img src="https://avatars3.githubusercontent.com/u/464978?v=4" width="100px;"/><br /><sub><b>Alejandro Ñáñez Ortiz</b></sub>](http://co.linkedin.com/in/alejandronanez/)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=alejandronanez "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/1402095?v=4" width="100px;"/><br /><sub><b>Matt Parrish</b></sub>](https://github.com/pbomb)<br />[🐛](https://github.com/kentcdodds/react-testing-library/issues?q=author%3Apbomb "Bug reports") [💻](https://github.com/kentcdodds/react-testing-library/commits?author=pbomb "Code") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=pbomb "Documentation") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=pbomb "Tests") | [<img src="https://avatars1.githubusercontent.com/u/1288694?v=4" width="100px;"/><br /><sub><b>Justin Hall</b></sub>](https://github.com/wKovacs64)<br />[📦](#platform-wKovacs64 "Packaging/porting to new platform") |
732729
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
733730
| [<img src="https://avatars1.githubusercontent.com/u/1241511?s=460&v=4" width="100px;"/><br /><sub><b>Anto Aravinth</b></sub>](https://github.com/antoaravinth)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=antoaravinth "Code") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=antoaravinth "Tests") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=antoaravinth "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/3462296?v=4" width="100px;"/><br /><sub><b>Jonah Moses</b></sub>](https://github.com/JonahMoses)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=JonahMoses "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/4002543?v=4" width="100px;"/><br /><sub><b>Łukasz Gandecki</b></sub>](http://team.thebrain.pro)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=lgandecki "Code") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=lgandecki "Tests") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=lgandecki "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/498274?v=4" width="100px;"/><br /><sub><b>Ivan Babak</b></sub>](https://sompylasar.github.io)<br />[🐛](https://github.com/kentcdodds/react-testing-library/issues?q=author%3Asompylasar "Bug reports") [🤔](#ideas-sompylasar "Ideas, Planning, & Feedback") | [<img src="https://avatars3.githubusercontent.com/u/4439618?v=4" width="100px;"/><br /><sub><b>Jesse Day</b></sub>](https://github.com/jday3)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=jday3 "Code") | [<img src="https://avatars0.githubusercontent.com/u/15199?v=4" width="100px;"/><br /><sub><b>Ernesto García</b></sub>](http://gnapse.github.io)<br />[💬](#question-gnapse "Answering Questions") [💻](https://github.com/kentcdodds/react-testing-library/commits?author=gnapse "Code") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=gnapse "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/2747424?v=4" width="100px;"/><br /><sub><b>Josef Maxx Blake</b></sub>](http://jomaxx.com)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=jomaxx "Code") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=jomaxx "Documentation") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=jomaxx "Tests") |
734-
| [<img src="https://avatars1.githubusercontent.com/u/29602306?v=4" width="100px;"/><br /><sub><b>Michal Baranowski</b></sub>](https://twitter.com/baranovskim)<br />[📝](#blog-mbaranovski "Blogposts") [✅](#tutorial-mbaranovski "Tutorials") | [<img src="https://avatars3.githubusercontent.com/u/13985684?v=4" width="100px;"/><br /><sub><b>Arthur Puthin</b></sub>](https://github.com/aputhin)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=aputhin "Documentation") |
735-
731+
| [<img src="https://avatars1.githubusercontent.com/u/29602306?v=4" width="100px;"/><br /><sub><b>Michal Baranowski</b></sub>](https://twitter.com/baranovskim)<br />[📝](#blog-mbaranovski "Blogposts") [✅](#tutorial-mbaranovski "Tutorials") | [<img src="https://avatars3.githubusercontent.com/u/13985684?v=4" width="100px;"/><br /><sub><b>Arthur Puthin</b></sub>](https://github.com/aputhin)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=aputhin "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/21194045?v=4" width="100px;"/><br /><sub><b>Thomas Chia</b></sub>](https://github.com/thchia)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=thchia "Code") [🚇](#infra-thchia "Infrastructure (Hosting, Build-Tools, etc)") [🔧](#tool-thchia "Tools") | [<img src="https://avatars3.githubusercontent.com/u/20430611?v=4" width="100px;"/><br /><sub><b>Thiago Galvani</b></sub>](http://ilegra.com/)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=thiagopaiva99 "Documentation") |
736732
<!-- ALL-CONTRIBUTORS-LIST:END -->
737733

738734
This project follows the [all-contributors][all-contributors] specification.

typings/index.d.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import {Simulate as ReactSimulate} from 'react-dom/test-utils'
22

3+
type TextMatchFunction = (content: string, element: HTMLElement) => boolean
4+
type TextMatch = string | RegExp | TextMatchFunction
5+
36
interface RenderResult {
47
container: HTMLDivElement
58
unmount: VoidFunction
6-
queryByTestId: (id: string) => HTMLElement | null
7-
getByTestId: (id: string) => HTMLElement
8-
queryByText: (id: string) => HTMLElement | null
9-
getByText: (id: string) => HTMLElement
10-
queryByPlaceholderText: (id: string) => HTMLElement | null
11-
getByPlaceholderText: (id: string) => HTMLElement
12-
queryByLabelText: (id: string) => HTMLElement | null
13-
getByLabelText: (id: string) => HTMLElement
14-
queryByAltText: (text: string) => HTMLElement | null
15-
getByAltText: (text: string) => HTMLElement
9+
queryByTestId: (id: TextMatch) => HTMLElement | null
10+
getByTestId: (id: TextMatch) => HTMLElement
11+
queryByText: (id: TextMatch) => HTMLElement | null
12+
getByText: (text: TextMatch) => HTMLElement
13+
queryByPlaceholderText: (id: TextMatch) => HTMLElement | null
14+
getByPlaceholderText: (text: TextMatch) => HTMLElement
15+
queryByLabelText: (text: TextMatch) => HTMLElement | null
16+
getByLabelText: (id: TextMatch, options?: {selector: string}) => HTMLElement
17+
queryByAltText: (text: TextMatch) => HTMLElement | null
18+
getByAltText: (text: TextMatch) => HTMLElement
1619
}
1720

1821
export function render(

0 commit comments

Comments
 (0)