Skip to content

Commit 136c8e4

Browse files
committed
fix(TS): add missing types
1 parent aee7d58 commit 136c8e4

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ change the state of the checkbox.
5252

5353
- [Installation](#installation)
5454
- [API](#api)
55-
- [`click(element)`](#clickelement)
56-
- [`dblClick(element)`](#dblclickelement)
55+
- [`click(element, eventInit, options)`](#clickelement-eventinit-options)
56+
- [`dblClick(element, eventInit, options)`](#dblclickelement-eventinit-options)
5757
- [`async type(element, text, [options])`](#async-typeelement-text-options)
5858
- [`upload(element, file, [{ clickInit, changeInit }])`](#uploadelement-file--clickinit-changeinit-)
5959
- [`clear(element)`](#clearelement)
@@ -95,7 +95,7 @@ var userEvent = require('@testing-library/user-event')
9595

9696
## API
9797

98-
### `click(element)`
98+
### `click(element, eventInit, options)`
9999

100100
Clicks `element`, depending on what `element` is it can have different side
101101
effects.
@@ -128,7 +128,10 @@ See the
128128
[`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
129129
constructor documentation for more options.
130130

131-
### `dblClick(element)`
131+
Note that `click` will trigger hover events before clicking. To disable this,
132+
set the `skipHover` option to `true`.
133+
134+
### `dblClick(element, eventInit, options)`
132135

133136
Clicks `element` twice, depending on what `element` is it can have different
134137
side effects.
@@ -169,6 +172,9 @@ test('type', async () => {
169172
are typed. By default it's 0. You can use this option if your component has a
170173
different behavior for fast or slow users.
171174

175+
`type` will click the element before typing. To disable this, set the
176+
`skipClick` option to `true`.
177+
172178
#### Special characters
173179

174180
The following special character strings are supported:
@@ -187,7 +193,9 @@ The following special character strings are supported:
187193

188194
> **A note about modifiers:** Modifier keys (`{shift}`, `{ctrl}`, `{alt}`,
189195
> `{meta}`) will activate their corresponding event modifiers for the duration
190-
> of type command or until they are closed (via `{/shift}`, `{/ctrl}`, etc.).
196+
> of type command or until they are closed (via `{/shift}`, `{/ctrl}`, etc.). If
197+
> they are not closed explicitly, then events will be fired to close them
198+
> automatically (to disable this, set the `skipAutoClose` option to `true`).
191199
192200
<!-- space out these notes -->
193201

typings/index.d.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Definitions by: Wu Haotian <https://github.com/whtsky>
22
export interface ITypeOpts {
3+
skipClick?: boolean
4+
skipAutoClose?: boolean
35
delay?: number
46
initialSelectionStart?: number
57
initialSelectionEnd?: number
@@ -19,10 +21,23 @@ export type UploadInitArgument = {
1921
changeInit?: Event
2022
}
2123

24+
export interface IClickOptions {
25+
skipHover?: boolean
26+
clickCount?: number
27+
}
28+
2229
declare const userEvent: {
2330
clear: (element: TargetElement) => void
24-
click: (element: TargetElement, init?: MouseEventInit) => void
25-
dblClick: (element: TargetElement, init?: MouseEventInit) => void
31+
click: (
32+
element: TargetElement,
33+
init?: MouseEventInit,
34+
options?: IClickOptions,
35+
) => void
36+
dblClick: (
37+
element: TargetElement,
38+
init?: MouseEventInit,
39+
options?: IClickOptions,
40+
) => void
2641
selectOptions: (
2742
element: TargetElement,
2843
values: string | string[] | HTMLElement | HTMLElement[],

0 commit comments

Comments
 (0)