Skip to content

Commit 489e089

Browse files
committed
chore: remove type definitions from headings
1 parent 3bf940a commit 489e089

File tree

1 file changed

+82
-19
lines changed

1 file changed

+82
-19
lines changed

README.md

Lines changed: 82 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ when a real user uses it.
7272

7373
* [Installation](#installation)
7474
* [Usage](#usage)
75-
* [`getByLabelText(container: HTMLElement, text: TextMatch, options: {selector: string = '*', exact: boolean = true}): HTMLElement`](#getbylabeltextcontainer-htmlelement-text-textmatch-options-selector-string---exact-boolean--true-htmlelement)
76-
* [`getByPlaceholderText(container: HTMLElement, text: TextMatch, {exact: boolean = true}): HTMLElement`](#getbyplaceholdertextcontainer-htmlelement-text-textmatch-exact-boolean--true-htmlelement)
77-
* [`getByText(container: HTMLElement, text: TextMatch, {exact: boolean = true}): HTMLElement`](#getbytextcontainer-htmlelement-text-textmatch-exact-boolean--true-htmlelement)
78-
* [`getByAltText(container: HTMLElement, text: TextMatch, {exact: boolean = true}): HTMLElement`](#getbyalttextcontainer-htmlelement-text-textmatch-exact-boolean--true-htmlelement)
79-
* [`getByTestId(container: HTMLElement, text: ExactTextMatch, {exact: boolean = true}): HTMLElement`](#getbytestidcontainer-htmlelement-text-exacttextmatch-exact-boolean--true-htmlelement)
75+
* [`getByLabelText`](#getbylabeltext)
76+
* [`getByPlaceholderText`](#getbyplaceholdertext)
77+
* [`getByText`](#getbytext)
78+
* [`getByAltText`](#getbyalttext)
79+
* [`getByTestId`](#getbytestid)
8080
* [`wait`](#wait)
8181
* [`waitForElement`](#waitforelement)
82-
* [`fireEvent(node: HTMLElement, event: Event)`](#fireeventnode-htmlelement-event-event)
82+
* [`fireEvent`](#fireevent)
8383
* [Custom Jest Matchers](#custom-jest-matchers)
8484
* [Using other assertion libraries](#using-other-assertion-libraries)
8585
* [`TextMatch`](#textmatch)
@@ -182,7 +182,17 @@ test('examples of some things', async () => {
182182
})
183183
```
184184

185-
### `getByLabelText(container: HTMLElement, text: TextMatch, options: {selector: string = '*', exact: boolean = true}): HTMLElement`
185+
### `getByLabelText`
186+
187+
```typescript
188+
getByLabelText(
189+
container: HTMLElement,
190+
text: TextMatch,
191+
options?: {
192+
selector?: string = '*',
193+
exact?: boolean = true,
194+
}): HTMLElement
195+
```
186196

187197
This will search for the label that matches the given [`TextMatch`](#textmatch),
188198
then find the element associated with that label.
@@ -217,7 +227,16 @@ const inputNode = getByLabelText(container, 'username', {selector: 'input'})
217227
> want this behavior (for example you wish to assert that it doesn't exist),
218228
> then use `queryByLabelText` instead.
219229
220-
### `getByPlaceholderText(container: HTMLElement, text: TextMatch, {exact: boolean = true}): HTMLElement`
230+
### `getByPlaceholderText`
231+
232+
```typescript
233+
getByPlaceholderText(
234+
container: HTMLElement,
235+
text: TextMatch,
236+
options?: {
237+
exact?: boolean = true,
238+
}): HTMLElement
239+
```
221240

222241
This will search for all elements with a placeholder attribute and find one
223242
that matches the given [`TextMatch`](#textmatch).
@@ -230,7 +249,16 @@ const inputNode = getByPlaceholderText(container, 'Username')
230249
> NOTE: a placeholder is not a good substitute for a label so you should
231250
> generally use `getByLabelText` instead.
232251
233-
### `getByText(container: HTMLElement, text: TextMatch, {exact: boolean = true}): HTMLElement`
252+
### `getByText`
253+
254+
```typescript
255+
getByText(
256+
container: HTMLElement,
257+
text: TextMatch,
258+
options?: {
259+
exact?: boolean = true,
260+
}): HTMLElement
261+
```
234262

235263
This will search for all elements that have a text node with `textContent`
236264
matching the given [`TextMatch`](#textmatch).
@@ -240,7 +268,16 @@ matching the given [`TextMatch`](#textmatch).
240268
const aboutAnchorNode = getByText(container, 'about')
241269
```
242270

243-
### `getByAltText(container: HTMLElement, text: TextMatch, {exact: boolean = true}): HTMLElement`
271+
### `getByAltText`
272+
273+
```typescript
274+
getByAltText(
275+
container: HTMLElement,
276+
text: TextMatch,
277+
options?: {
278+
exact?: boolean = true,
279+
}): HTMLElement
280+
```
244281

245282
This will return the element (normally an `<img>`) that has the given `alt`
246283
text. Note that it only supports elements which accept an `alt` attribute:
@@ -254,7 +291,16 @@ and [`<area>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/area)
254291
const incrediblesPosterImg = getByAltText(container, /incredibles.*poster$/i)
255292
```
256293

257-
### `getByTitle(container: HTMLElement, title: ExactTextMatch): HTMLElement`
294+
### `getByTitle`
295+
296+
```typescript
297+
getByTitle(
298+
container: HTMLElement,
299+
title: TextMatch,
300+
options?: {
301+
exact?: boolean = true,
302+
}): HTMLElement
303+
```
258304

259305
This will return the element that has the matching `title` attribute.
260306

@@ -263,7 +309,16 @@ This will return the element that has the matching `title` attribute.
263309
const deleteElement = getByTitle(container, 'Delete')
264310
```
265311

266-
### `getByTestId(container: HTMLElement, text: ExactTextMatch, {exact: boolean = true}): HTMLElement`
312+
### `getByTestId`
313+
314+
```typescript
315+
getByTestId(
316+
container: HTMLElement,
317+
text: ExactTextMatch,
318+
options?: {
319+
exact?: boolean = true,
320+
}): HTMLElement`
321+
```
267322

268323
A shortcut to `` container.querySelector(`[data-testid="${yourId}"]`) `` (and it
269324
also accepts an [`ExactTextMatch`](#exacttextmatch)).
@@ -283,8 +338,6 @@ const usernameInputElement = getByTestId(container, 'username-input')
283338

284339
### `wait`
285340

286-
Defined as:
287-
288341
```typescript
289342
function wait(
290343
callback?: () => void,
@@ -326,8 +379,6 @@ intervals.
326379

327380
### `waitForElement`
328381

329-
Defined as:
330-
331382
```typescript
332383
function waitForElement<T>(
333384
callback?: () => T | null | undefined,
@@ -386,7 +437,11 @@ The default `timeout` is `4500ms` which will keep you under
386437
additions and removals of child elements (including text nodes) in the `container` and any of its descendants.
387438
It won't detect attribute changes unless you add `attributes: true` to the options.
388439

389-
### `fireEvent(node: HTMLElement, event: Event)`
440+
### `fireEvent`
441+
442+
```typescript
443+
fireEvent(node: HTMLElement, event: Event)
444+
```
390445

391446
Fire DOM events.
392447

@@ -401,7 +456,11 @@ fireEvent(
401456
)
402457
```
403458

404-
#### `fireEvent[eventName](node: HTMLElement, eventProperties: Object)`
459+
#### `fireEvent[eventName]`
460+
461+
```typescript
462+
fireEvent[eventName](node: HTMLElement, eventProperties: Object)
463+
```
405464

406465
Convenience methods for firing DOM events. Check out
407466
[src/events.js](https://github.com/kentcdodds/dom-testing-library/blob/master/src/events.js)
@@ -414,7 +473,11 @@ fireEvent.click(getElementByText('Submit'), rightClick)
414473
// default `button` property for click events is set to `0` which is a left click.
415474
```
416475

417-
#### `getNodeText(node: HTMLElement)`
476+
#### `getNodeText`
477+
478+
```typescript
479+
getNodeText(node: HTMLElement)
480+
```
418481

419482
Returns the complete text content of a html element, removing any extra
420483
whitespace. The intention is to treat text in nodes exactly as how it is

0 commit comments

Comments
 (0)