mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
Add definitions for user-event
This commit is contained in:
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Type definitions for user-event 1.4
|
||||
// Project: https://github.com/Gpx/user-event#readme
|
||||
// Definitions by: Wu Haotian <https://github.com/whtsky>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface UserOpts {
|
||||
allAtOnce?: boolean;
|
||||
delay?: number;
|
||||
}
|
||||
declare const userEvent: {
|
||||
click: (element: Element | Window) => void;
|
||||
dblClick: (element: Element | Window) => void;
|
||||
type: (
|
||||
element: Element | Window,
|
||||
text: string,
|
||||
userOpts?: UserOpts
|
||||
) => Promise<void>;
|
||||
};
|
||||
|
||||
export default userEvent;
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["dom", "es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "user-event-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,11 @@
|
||||
import userEvent, { UserOpts } from "user-event";
|
||||
|
||||
userEvent.click(document.body); // $ExpectType void
|
||||
userEvent.dblClick(window); // $ExpectType void
|
||||
userEvent.type(document.body, "s"); // $ExpectType Promise<void>
|
||||
userEvent.type(document.body, "s", {}); // $ExpectType Promise<void>
|
||||
userEvent.type(document.body, "s", { delay: 5000 }); // $ExpectType Promise<void>
|
||||
userEvent.type(document.body, "s", { allAtOnce: true }); // $ExpectType Promise<void>
|
||||
userEvent.type(document.body, "s", { delay: 1000, allAtOnce: false }); // $ExpectType Promise<void>
|
||||
|
||||
const u: UserOpts = { delay: 20 };
|
||||
Reference in New Issue
Block a user