Updated type defs for @testing-library/user-event (#36444)

* fix: updated the type definitions for @testing-library/user-event

* just make changes to testing-library__user-event

* take 2

* updated type defs

* cleaned up formatting

* fix naming

* attempt to fix the type defs

* chore: updated tsconfig.json

* remove whitespace

* fix whitespace

* chore: attempt to fix both user-event packages

* chore: formatting code
This commit is contained in:
Weyert de Boer
2019-06-26 13:51:22 +01:00
committed by John Reilly
parent 2ceda6e7ea
commit cfc586791d
4 changed files with 17 additions and 13 deletions
+4 -6
View File
@@ -1,4 +1,4 @@
// Type definitions for @testing-library/user-event 4.0
// Type definitions for @testing-library/user-event 4.1
// Project: https://github.com/testing-library/user-event
// Definitions by: Wu Haotian <https://github.com/whtsky>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -7,14 +7,12 @@ 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>;
selectOptions: (element: Element | Window, values: string | string[]) => void;
type: (element: Element | Window, text: string, userOpts?: UserOpts) => Promise<void>;
};
export default userEvent;
@@ -1,7 +1,9 @@
import userEvent, { UserOpts } from "user-event";
import userEvent, { UserOpts } from 'user-event';
userEvent.click(document.body); // $ExpectType void
userEvent.dblClick(window); // $ExpectType void
userEvent.selectOptions(window, 'test'); // $ExpectType void
userEvent.selectOptions(window, ['test1', 'test2']); // $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>
@@ -12,5 +12,10 @@
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"paths": {
"@testing-library/user-event": [
"testing-library__user-event"
]
},
"files": ["index.d.ts", "testing-library__user-event-tests.ts"]
}
+5 -6
View File
@@ -1,4 +1,4 @@
// Type definitions for user-event 1.4
// Type definitions for user-event 4.1
// Project: https://github.com/testing-library/user-event
// Definitions by: Wu Haotian <https://github.com/whtsky>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -10,11 +10,10 @@ export interface UserOpts {
declare const userEvent: {
click: (element: Element | Window) => void;
dblClick: (element: Element | Window) => void;
type: (
element: Element | Window,
text: string,
userOpts?: UserOpts
) => Promise<void>;
selectOptions: (element: Element | Window, values: string | string[]) => void;
type: (element: Element | Window, text: string, userOpts?: UserOpts) => Promise<void>;
};
export default userEvent;