-
Notifications
You must be signed in to change notification settings - Fork 244
/
index.d.ts
90 lines (82 loc) · 2.13 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
// Definitions by: Wu Haotian <https://github.com/whtsky>
export interface ITypeOpts {
skipClick?: boolean
skipAutoClose?: boolean
delay?: number
initialSelectionStart?: number
initialSelectionEnd?: number
}
export interface ITabUserOptions {
shift?: boolean
focusTrap?: Document | Element
}
export type TargetElement = Element | Window
export type FilesArgument = File | File[]
export type UploadInitArgument = {
clickInit?: MouseEventInit
changeInit?: Event
}
export interface IClickOptions {
skipHover?: boolean
clickCount?: number
}
declare const userEvent: {
clear: (element: TargetElement) => void
click: (
element: TargetElement,
init?: MouseEventInit,
options?: IClickOptions,
) => void
dblClick: (
element: TargetElement,
init?: MouseEventInit,
options?: IClickOptions,
) => void
selectOptions: (
element: TargetElement,
values: string | string[] | HTMLElement | HTMLElement[],
init?: MouseEventInit,
) => void
deselectOptions: (
element: TargetElement,
values: string | string[] | HTMLElement | HTMLElement[],
init?: MouseEventInit,
) => void
upload: (
element: TargetElement,
files: FilesArgument,
init?: UploadInitArgument,
) => void
type: <T extends ITypeOpts>(
element: TargetElement,
text: string,
userOpts?: T,
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
) => T extends {delay: number} ? Promise<void> : void
tab: (userOpts?: ITabUserOptions) => void
paste: (
element: TargetElement,
text: string,
init?: MouseEventInit,
pasteOptions?: {
initialSelectionStart?: number
initialSelectionEnd?: number
},
) => void
hover: (element: TargetElement, init?: MouseEventInit) => void
unhover: (element: TargetElement, init?: MouseEventInit) => void
}
export default userEvent
export enum specialChars {
arrowLeft = '{arrowleft}',
arrowRight = '{arrowright}',
arrowDown = '{arrowdown}',
arrowUp = '{arrowup}',
enter = '{enter}',
escape = '{esc}',
delete = '{del}',
backspace = '{backspace}',
selectAll = '{selectall}',
space = '{space}',
whitespace = ' ',
}