forked from testing-library/react-testing-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
168 lines (157 loc) · 3.83 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import {Simulate as ReactSimulate} from 'react-dom/test-utils'
import {
AllByAttribute,
AllByText,
BoundFunction,
GetByAttribute,
GetByText,
QueryByAttribute,
QueryByText,
} from 'dom-testing-library'
export {prettyDOM} from 'dom-testing-library'
type TextMatchFunction = (content: string, element: HTMLElement) => boolean
type TextMatch = string | RegExp | TextMatchFunction
type TextMatchOptions = {
exact?: boolean
trim?: boolean
collapseWhitespace?: boolean
}
interface GetsAndQueries {
queryByTestId: BoundFunction<QueryByAttribute>
queryAllByTestId: BoundFunction<AllByAttribute>
getByTestId: BoundFunction<GetByAttribute>
getAllByTestId: BoundFunction<AllByAttribute>
queryByText: BoundFunction<QueryByText>
queryAllByText: BoundFunction<AllByText>
getByText: BoundFunction<GetByText>
getAllByText: BoundFunction<AllByText>
queryByPlaceholderText: BoundFunction<QueryByAttribute>
queryAllByPlaceholderText: BoundFunction<AllByAttribute>
getByPlaceholderText: BoundFunction<GetByAttribute>
getAllByPlaceholderText: BoundFunction<AllByAttribute>
queryByLabelText: BoundFunction<QueryByAttribute>
queryAllByLabelText: BoundFunction<AllByAttribute>
getByLabelText: BoundFunction<GetByAttribute>
getAllByLabelText: BoundFunction<AllByAttribute>
queryByAltText: BoundFunction<QueryByAttribute>
queryAllByAltText: BoundFunction<AllByAttribute>
getByAltText: BoundFunction<GetByAttribute>
getAllByAltText: BoundFunction<AllByAttribute>
}
export interface RenderResult extends GetsAndQueries {
container: HTMLDivElement
debug: () => void
rerender: (ui: React.ReactElement<any>) => void
unmount: VoidFunction
}
/**
* Render into a container which is appended to document.body. It should be used with cleanup.
*/
export function render(
ui: React.ReactElement<any>,
options?: {container: HTMLElement; baseElement: HTMLElement},
): RenderResult
/**
* When in need to wait for DOM elements to appear, disappear, or change. Prefer waitForElement.
*/
export function wait(
callback?: () => void,
options?: {
timeout?: number
interval?: number
},
): Promise<void>
/**
* When in need to wait for DOM elements to appear, disappear, or change.
*/
export function waitForElement<T>(
callback?: () => T,
options?: {
container?: HTMLElement
timeout?: number
mutationObserverOptions?: MutationObserverInit
},
): Promise<T | undefined>
type EventType =
| 'copy'
| 'cut'
| 'paste'
| 'compositionEnd'
| 'compositionStart'
| 'compositionUpdate'
| 'keyDown'
| 'keyPress'
| 'keyUp'
| 'focus'
| 'blur'
| 'change'
| 'input'
| 'invalid'
| 'submit'
| 'click'
| 'contextMenu'
| 'dblClick'
| 'drag'
| 'dragEnd'
| 'dragEnter'
| 'dragExit'
| 'dragLeave'
| 'dragOver'
| 'dragStart'
| 'drop'
| 'mouseDown'
| 'mouseEnter'
| 'mouseLeave'
| 'mouseMove'
| 'mouseOut'
| 'mouseOver'
| 'mouseUp'
| 'select'
| 'touchCancel'
| 'touchEnd'
| 'touchMove'
| 'touchStart'
| 'scroll'
| 'wheel'
| 'abort'
| 'canPlay'
| 'canPlayThrough'
| 'durationChange'
| 'emptied'
| 'encrypted'
| 'ended'
| 'loadedData'
| 'loadedMetadata'
| 'loadStart'
| 'pause'
| 'play'
| 'playing'
| 'progress'
| 'rateChange'
| 'seeked'
| 'seeking'
| 'stalled'
| 'suspend'
| 'timeUpdate'
| 'volumeChange'
| 'waiting'
| 'load'
| 'error'
| 'animationStart'
| 'animationEnd'
| 'animationIteration'
| 'transitionEnd'
| 'doubleClick'
type FireFunction = (element: HTMLElement, event: Event) => boolean
type FireObject = {
[K in EventType]: (element: HTMLElement, options?: {}) => boolean
}
/**
* Fire DOM events.
*/
export const fireEvent: FireFunction & FireObject
/**
* Unmounts React trees that were mounted with render.
*/
export function cleanup(): void
export function getQueriesForElement(element: HTMLElement): GetsAndQueries