Copied user-event definition to new testing-library organization (#36000)

This commit is contained in:
Adam Binford 2019-06-07 21:33:20 -04:00 committed by Andrew Casey
parent 695e81c90d
commit 4b88e01657
4 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,20 @@
// Type definitions for @testing-library/user-event 4.0
// Project: https://github.com/testing-library/user-event
// 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;

View File

@ -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 };

View File

@ -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", "testing-library__user-event-tests.ts"]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }