@testing-library/user-event 14.0.0-beta.6 → 14.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { inputDeviceState } from '../setup';
1
+ import { Config } from '../setup';
2
2
  import { PointerTarget, SelectionTarget } from './types';
3
3
  export interface PointerMoveAction extends PointerTarget, SelectionTarget {
4
4
  pointerName?: string;
5
5
  }
6
- export declare function pointerMove({ pointerName, target, coords, node, offset }: PointerMoveAction, { pointerState, keyboardState }: inputDeviceState): Promise<void>;
6
+ export declare function pointerMove(config: Config, { pointerName, target, coords, node, offset }: PointerMoveAction): Promise<void>;
@@ -1,8 +1,8 @@
1
- import { inputDeviceState } from '../setup';
1
+ import { Config } from '../setup';
2
2
  import type { pointerKey, PointerTarget, SelectionTarget } from './types';
3
3
  export interface PointerPressAction extends PointerTarget, SelectionTarget {
4
4
  keyDef: pointerKey;
5
5
  releasePrevious: boolean;
6
6
  releaseSelf: boolean;
7
7
  }
8
- export declare function pointerPress(action: PointerPressAction, state: inputDeviceState): Promise<void>;
8
+ export declare function pointerPress(config: Config, action: PointerPressAction): Promise<void>;
@@ -1,4 +1,3 @@
1
- import type { PointerOptions } from '../utils';
2
1
  import type { PointerInput } from '../pointer';
3
2
  import type { UserEventApi } from '.';
4
3
  import { Config } from './config';
@@ -15,6 +14,6 @@ export declare function paste(clipboardData?: DataTransfer | string, options?: P
15
14
  export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
16
15
  export declare function tripleClick(element: Element, options?: Partial<Config>): Promise<void>;
17
16
  export declare function type(element: Element, text: string, options?: Partial<Config> & Parameters<UserEventApi['type']>[2]): Promise<void>;
18
- export declare function unhover(element: Element, options?: PointerOptions): Promise<void>;
17
+ export declare function unhover(element: Element, options?: Partial<Config>): Promise<void>;
19
18
  export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: Partial<Config>): Promise<void>;
20
19
  export declare function tab(options?: Partial<Config> & Parameters<UserEventApi['tab']>[0]): Promise<void>;
@@ -5,10 +5,14 @@ import * as directApi from './directApi';
5
5
  export type { inputDeviceState };
6
6
  export { Config };
7
7
  export declare type UserEventApi = typeof userEventApi;
8
- export declare type UserEvent = UserEventApi & {
9
- readonly setup: typeof setupSub;
8
+ export declare type Instance = UserEventApi & {
10
9
  [Config]: Config;
11
10
  };
11
+ export declare type UserEvent = {
12
+ readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
13
+ } & {
14
+ readonly [k in keyof UserEventApi]: (...args: Parameters<UserEventApi[k]>) => ReturnType<UserEventApi[k]>;
15
+ };
12
16
  export declare const userEvent: {
13
17
  readonly setup: typeof setupMain;
14
18
  readonly clear: typeof directApi.clear;
@@ -1,74 +1,19 @@
1
1
  import { Options } from '../options';
2
- import type { UserEvent } from './index';
2
+ import type { Instance, UserEvent } from './index';
3
3
  import { Config } from './config';
4
- import * as userEventApi from './api';
5
4
  /**
6
5
  * Start a "session" with userEvent.
7
6
  * All APIs returned by this function share an input device state and a default configuration.
8
7
  */
9
- export declare function setupMain(options?: Options): {
10
- setup: typeof setupSub;
11
- [Config]: Config;
12
- click: typeof userEventApi.click;
13
- dblClick: typeof userEventApi.dblClick;
14
- tripleClick: typeof userEventApi.tripleClick;
15
- hover: typeof userEventApi.hover;
16
- unhover: typeof userEventApi.unhover;
17
- tab: typeof userEventApi.tab;
18
- keyboard: typeof userEventApi.keyboard;
19
- copy: typeof userEventApi.copy;
20
- cut: typeof userEventApi.cut;
21
- paste: typeof userEventApi.paste;
22
- pointer: typeof userEventApi.pointer;
23
- clear: typeof userEventApi.clear;
24
- deselectOptions: typeof userEventApi.deselectOptions;
25
- selectOptions: typeof userEventApi.selectOptions;
26
- type: typeof userEventApi.type;
27
- upload: typeof userEventApi.upload;
28
- };
8
+ export declare function setupMain(options?: Options): UserEvent;
29
9
  /**
30
10
  * Setup in direct call per `userEvent.anyApi()`
31
11
  */
32
12
  export declare function setupDirect(options?: Partial<Config>, node?: Node): {
33
- setup: typeof setupSub;
34
- [Config]: Config;
35
- click: typeof userEventApi.click;
36
- dblClick: typeof userEventApi.dblClick;
37
- tripleClick: typeof userEventApi.tripleClick;
38
- hover: typeof userEventApi.hover;
39
- unhover: typeof userEventApi.unhover;
40
- tab: typeof userEventApi.tab;
41
- keyboard: typeof userEventApi.keyboard;
42
- copy: typeof userEventApi.copy;
43
- cut: typeof userEventApi.cut;
44
- paste: typeof userEventApi.paste;
45
- pointer: typeof userEventApi.pointer;
46
- clear: typeof userEventApi.clear;
47
- deselectOptions: typeof userEventApi.deselectOptions;
48
- selectOptions: typeof userEventApi.selectOptions;
49
- type: typeof userEventApi.type;
50
- upload: typeof userEventApi.upload;
13
+ config: Config;
14
+ api: UserEvent;
51
15
  };
52
16
  /**
53
17
  * Create a set of callbacks with different default settings but the same state.
54
18
  */
55
- export declare function setupSub(this: UserEvent, options: Options): {
56
- setup: typeof setupSub;
57
- [Config]: Config;
58
- click: typeof userEventApi.click;
59
- dblClick: typeof userEventApi.dblClick;
60
- tripleClick: typeof userEventApi.tripleClick;
61
- hover: typeof userEventApi.hover;
62
- unhover: typeof userEventApi.unhover;
63
- tab: typeof userEventApi.tab;
64
- keyboard: typeof userEventApi.keyboard;
65
- copy: typeof userEventApi.copy;
66
- cut: typeof userEventApi.cut;
67
- paste: typeof userEventApi.paste;
68
- pointer: typeof userEventApi.pointer;
69
- clear: typeof userEventApi.clear;
70
- deselectOptions: typeof userEventApi.deselectOptions;
71
- selectOptions: typeof userEventApi.selectOptions;
72
- type: typeof userEventApi.type;
73
- upload: typeof userEventApi.upload;
74
- };
19
+ export declare function setupSub(this: Instance, options: Options): UserEvent;
@@ -1,2 +1,2 @@
1
- import type { UserEvent } from '../setup';
2
- export declare function clear(this: UserEvent, element: Element): Promise<void>;
1
+ import type { Instance } from '../setup';
2
+ export declare function clear(this: Instance, element: Element): Promise<void>;
@@ -1,3 +1,3 @@
1
- import { UserEvent } from '../setup';
2
- export declare function selectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
3
- export declare function deselectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
1
+ import { Instance } from '../setup';
2
+ export declare function selectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
3
+ export declare function deselectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { UserEvent } from '../setup';
1
+ import type { Instance } from '../setup';
2
2
  import { Config } from '../setup/config';
3
3
  export interface typeOptions {
4
4
  skipClick?: Config['skipClick'];
@@ -6,4 +6,4 @@ export interface typeOptions {
6
6
  initialSelectionStart?: number;
7
7
  initialSelectionEnd?: number;
8
8
  }
9
- export declare function type(this: UserEvent, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;
9
+ export declare function type(this: Instance, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;
@@ -1,5 +1,5 @@
1
- import { UserEvent } from '../setup';
1
+ import { Instance } from '../setup';
2
2
  export interface uploadInit {
3
3
  changeInit?: EventInit;
4
4
  }
5
- export declare function upload(this: UserEvent, element: HTMLElement, fileOrFiles: File | File[]): Promise<void>;
5
+ export declare function upload(this: Instance, element: HTMLElement, fileOrFiles: File | File[]): Promise<void>;
@@ -34,8 +34,9 @@ export * from './misc/isDescendantOrSelf';
34
34
  export * from './misc/isElementType';
35
35
  export * from './misc/isVisible';
36
36
  export * from './misc/isDisabled';
37
+ export * from './misc/level';
37
38
  export * from './misc/wait';
38
- export * from './misc/hasPointerEvents';
39
39
  export * from './misc/hasFormSubmit';
40
+ export * from './pointer/cssPointerEvents';
40
41
  export * from './pointer/firePointerEvents';
41
42
  export * from './pointer/mouseButtons';
@@ -0,0 +1,17 @@
1
+ import { Config } from '../../setup';
2
+ export declare enum ApiLevel {
3
+ Trigger = 2,
4
+ Call = 1
5
+ }
6
+ declare const Level: unique symbol;
7
+ interface LevelRefs {
8
+ [k: number]: object | undefined;
9
+ }
10
+ declare module '../../setup' {
11
+ interface Config {
12
+ [Level]?: LevelRefs;
13
+ }
14
+ }
15
+ export declare function setLevelRef(config: Config, level: ApiLevel): void;
16
+ export declare function getLevelRef(config: Config, level: ApiLevel): object | undefined;
17
+ export {};
@@ -0,0 +1,15 @@
1
+ import { Config } from '../../setup';
2
+ import { ApiLevel } from '..';
3
+ export declare function hasPointerEvents(element: Element): boolean;
4
+ declare const PointerEventsCheck: unique symbol;
5
+ declare global {
6
+ interface Element {
7
+ [PointerEventsCheck]?: {
8
+ [k in ApiLevel]?: object;
9
+ } & {
10
+ result: boolean;
11
+ };
12
+ }
13
+ }
14
+ export declare function assertPointerEvents(config: Config, element: Element): void;
15
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.0.0-beta.6",
3
+ "version": "14.0.0-beta.7",
4
4
  "description": "Fire events the same way the user does",
5
5
  "keywords": [
6
6
  "react-testing-library",
@@ -1,15 +0,0 @@
1
- /**
2
- * Options that can be passed to any event that relies
3
- * on pointer-events property
4
- */
5
- export declare interface PointerOptions {
6
- /**
7
- * When set to `true` the event skips checking if any element
8
- * in the DOM-tree has `'pointer-events: none'` set. This check is
9
- * costly in general and very costly when rendering large DOM-trees.
10
- * Can be used to speed up tests.
11
- * Default: `false`
12
- * */
13
- skipPointerEventsCheck?: boolean;
14
- }
15
- export declare function hasPointerEvents(element: Element): boolean;