@testing-library/user-event 14.0.0-alpha.14 → 14.0.0-alpha.15

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.
Files changed (76) hide show
  1. package/dist/clipboard/copy.d.ts +2 -11
  2. package/dist/clipboard/copy.js +10 -4
  3. package/dist/clipboard/cut.d.ts +2 -11
  4. package/dist/clipboard/cut.js +10 -4
  5. package/dist/clipboard/paste.d.ts +2 -6
  6. package/dist/clipboard/paste.js +7 -5
  7. package/dist/convenience/click.d.ts +4 -0
  8. package/dist/convenience/click.js +52 -0
  9. package/dist/convenience/hover.d.ts +3 -0
  10. package/dist/convenience/hover.js +31 -0
  11. package/dist/convenience/index.d.ts +3 -0
  12. package/dist/convenience/index.js +44 -0
  13. package/dist/convenience/tab.d.ts +4 -0
  14. package/dist/convenience/tab.js +12 -0
  15. package/dist/index.d.ts +2 -5
  16. package/dist/index.js +7 -8
  17. package/dist/keyboard/getNextKeyDef.d.ts +2 -2
  18. package/dist/keyboard/getNextKeyDef.js +4 -4
  19. package/dist/keyboard/index.d.ts +6 -17
  20. package/dist/keyboard/index.js +9 -43
  21. package/dist/keyboard/keyboardImplementation.d.ts +3 -3
  22. package/dist/keyboard/keyboardImplementation.js +47 -44
  23. package/dist/keyboard/plugins/character.js +16 -10
  24. package/dist/keyboard/plugins/combination.js +3 -1
  25. package/dist/keyboard/plugins/functional.js +38 -20
  26. package/dist/keyboard/types.d.ts +3 -12
  27. package/dist/options.d.ts +102 -0
  28. package/dist/options.js +36 -0
  29. package/dist/pointer/index.d.ts +6 -14
  30. package/dist/pointer/index.js +8 -42
  31. package/dist/pointer/parseKeyDef.d.ts +2 -2
  32. package/dist/pointer/parseKeyDef.js +1 -3
  33. package/dist/pointer/pointerAction.d.ts +3 -2
  34. package/dist/pointer/pointerAction.js +9 -15
  35. package/dist/pointer/pointerMove.d.ts +2 -1
  36. package/dist/pointer/pointerPress.d.ts +2 -1
  37. package/dist/pointer/types.d.ts +0 -11
  38. package/dist/setup/api.d.ts +5 -0
  39. package/dist/setup/api.js +111 -0
  40. package/dist/setup/config.d.ts +10 -0
  41. package/dist/setup/config.js +8 -0
  42. package/dist/setup/directApi.d.ts +21 -0
  43. package/dist/setup/directApi.js +95 -0
  44. package/dist/setup/index.d.ts +30 -0
  45. package/dist/setup/index.js +27 -0
  46. package/dist/setup/setup.d.ts +74 -0
  47. package/dist/setup/setup.js +98 -0
  48. package/dist/setup/wrapAsync.d.ts +4 -0
  49. package/dist/setup/wrapAsync.js +15 -0
  50. package/dist/{clear.d.ts → utility/clear.d.ts} +2 -2
  51. package/dist/{clear.js → utility/clear.js} +2 -5
  52. package/dist/utility/index.d.ts +4 -0
  53. package/dist/utility/index.js +57 -0
  54. package/dist/utility/selectOptions.d.ts +3 -0
  55. package/dist/{selectOptions.js → utility/selectOptions.js} +15 -24
  56. package/dist/utility/type.d.ts +9 -0
  57. package/dist/utility/type.js +37 -0
  58. package/dist/utility/upload.d.ts +5 -0
  59. package/dist/{upload.js → utility/upload.js} +6 -6
  60. package/dist/utils/index.d.ts +1 -0
  61. package/dist/utils/index.js +13 -0
  62. package/dist/utils/misc/getDocumentFromNode.d.ts +1 -0
  63. package/dist/utils/misc/getDocumentFromNode.js +14 -0
  64. package/package.json +1 -1
  65. package/dist/click.d.ts +0 -9
  66. package/dist/click.js +0 -61
  67. package/dist/hover.d.ts +0 -4
  68. package/dist/hover.js +0 -43
  69. package/dist/selectOptions.d.ts +0 -4
  70. package/dist/setup.d.ts +0 -100
  71. package/dist/setup.js +0 -241
  72. package/dist/tab.d.ts +0 -5
  73. package/dist/tab.js +0 -12
  74. package/dist/type.d.ts +0 -14
  75. package/dist/type.js +0 -74
  76. package/dist/upload.d.ts +0 -9
@@ -0,0 +1,9 @@
1
+ import type { UserEvent } from '../setup';
2
+ import { Config } from '../setup/config';
3
+ export interface typeOptions {
4
+ skipClick?: Config['skipClick'];
5
+ skipAutoClose?: Config['skipClick'];
6
+ initialSelectionStart?: number;
7
+ initialSelectionEnd?: number;
8
+ }
9
+ export declare function type(this: UserEvent, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.type = type;
7
+
8
+ var _utils = require("../utils");
9
+
10
+ var _keyboard = require("../keyboard");
11
+
12
+ var _config = require("../setup/config");
13
+
14
+ async function type(element, text, {
15
+ skipClick = this[_config.Config].skipClick,
16
+ skipAutoClose = this[_config.Config].skipAutoClose,
17
+ initialSelectionStart,
18
+ initialSelectionEnd
19
+ } = {}) {
20
+ // TODO: properly type guard
21
+ // we use this workaround for now to prevent changing behavior
22
+ if (element.disabled) return;
23
+
24
+ if (!skipClick) {
25
+ await this.click(element);
26
+ }
27
+
28
+ if (initialSelectionStart !== undefined) {
29
+ (0, _utils.setSelectionRange)(element, initialSelectionStart, initialSelectionEnd != null ? initialSelectionEnd : initialSelectionStart);
30
+ }
31
+
32
+ await this.keyboard(text);
33
+
34
+ if (!skipAutoClose) {
35
+ await (0, _keyboard.releaseAllKeys)(this[_config.Config]);
36
+ }
37
+ }
@@ -0,0 +1,5 @@
1
+ import { UserEvent } from '../setup';
2
+ export interface uploadInit {
3
+ changeInit?: EventInit;
4
+ }
5
+ export declare function upload(this: UserEvent, element: HTMLElement, fileOrFiles: File | File[], init?: uploadInit): Promise<void>;
@@ -7,11 +7,11 @@ exports.upload = upload;
7
7
 
8
8
  var _dom = require("@testing-library/dom");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils = require("../utils");
11
11
 
12
- function upload(element, fileOrFiles, init, {
13
- applyAccept = false
14
- } = {}) {
12
+ var _setup = require("../setup");
13
+
14
+ async function upload(element, fileOrFiles, init) {
15
15
  var _input$files;
16
16
 
17
17
  const input = (0, _utils.isElementType)(element, 'label') ? element.control : element;
@@ -23,8 +23,8 @@ function upload(element, fileOrFiles, init, {
23
23
  }
24
24
 
25
25
  if ((0, _utils.isDisabled)(element)) return;
26
- this.click(element);
27
- const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter(file => !applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1); // blur fires when the file selector pops up
26
+ await this.click(element);
27
+ const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter(file => !this[_setup.Config].applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1); // blur fires when the file selector pops up
28
28
 
29
29
  (0, _utils.blur)(element); // focus fires when they make their selection
30
30
 
@@ -25,6 +25,7 @@ export * from './focus/selector';
25
25
  export * from './keyDef/readNextDescriptor';
26
26
  export * from './misc/eventWrapper';
27
27
  export * from './misc/findClosest';
28
+ export * from './misc/getDocumentFromNode';
28
29
  export * from './misc/isDescendantOrSelf';
29
30
  export * from './misc/isElementType';
30
31
  export * from './misc/isVisible';
@@ -355,6 +355,19 @@ Object.keys(_findClosest).forEach(function (key) {
355
355
  });
356
356
  });
357
357
 
358
+ var _getDocumentFromNode = require("./misc/getDocumentFromNode");
359
+
360
+ Object.keys(_getDocumentFromNode).forEach(function (key) {
361
+ if (key === "default" || key === "__esModule") return;
362
+ if (key in exports && exports[key] === _getDocumentFromNode[key]) return;
363
+ Object.defineProperty(exports, key, {
364
+ enumerable: true,
365
+ get: function () {
366
+ return _getDocumentFromNode[key];
367
+ }
368
+ });
369
+ });
370
+
358
371
  var _isDescendantOrSelf = require("./misc/isDescendantOrSelf");
359
372
 
360
373
  Object.keys(_isDescendantOrSelf).forEach(function (key) {
@@ -0,0 +1 @@
1
+ export declare function getDocumentFromNode(el: Node): Document | null;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDocumentFromNode = getDocumentFromNode;
7
+
8
+ function getDocumentFromNode(el) {
9
+ return isDocument(el) ? el : el.ownerDocument;
10
+ }
11
+
12
+ function isDocument(node) {
13
+ return node.nodeType === 9;
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.0.0-alpha.14",
3
+ "version": "14.0.0-alpha.15",
4
4
  "description": "Fire events the same way the user does",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [
package/dist/click.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { PointerOptions } from './utils';
2
- import type { UserEvent } from './setup';
3
- export declare interface clickOptions {
4
- skipHover?: boolean;
5
- clickCount?: number;
6
- }
7
- export declare function click(this: UserEvent, element: Element, { skipHover, skipPointerEventsCheck, }?: clickOptions & PointerOptions): void;
8
- export declare function dblClick(this: UserEvent, element: Element, { skipPointerEventsCheck }?: clickOptions & PointerOptions): void;
9
- export declare function tripleClick(this: UserEvent, element: Element, { skipPointerEventsCheck }?: clickOptions & PointerOptions): void;
package/dist/click.js DELETED
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.click = click;
7
- exports.dblClick = dblClick;
8
- exports.tripleClick = tripleClick;
9
-
10
- var _utils = require("./utils");
11
-
12
- function click(element, {
13
- skipHover = false,
14
- skipPointerEventsCheck = false
15
- } = {}) {
16
- if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
17
- throw new Error('unable to click element as it has or inherits pointer-events set to "none".');
18
- } // istanbul ignore else
19
-
20
-
21
- if (!skipHover) // We just checked for `pointerEvents`. We can always skip this one in `hover`.
22
- this.hover(element, {
23
- skipPointerEventsCheck: true
24
- });
25
- this.pointer({
26
- keys: '[MouseLeft]',
27
- target: element
28
- });
29
- }
30
-
31
- function dblClick(element, {
32
- skipPointerEventsCheck = false
33
- } = {}) {
34
- if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
35
- throw new Error('unable to double-click element as it has or inherits pointer-events set to "none".');
36
- }
37
-
38
- this.hover(element, {
39
- skipPointerEventsCheck: true
40
- });
41
- this.pointer({
42
- keys: '[MouseLeft][MouseLeft]',
43
- target: element
44
- });
45
- }
46
-
47
- function tripleClick(element, {
48
- skipPointerEventsCheck = false
49
- } = {}) {
50
- if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
51
- throw new Error('unable to triple-click element as it has or inherits pointer-events set to "none".');
52
- }
53
-
54
- this.hover(element, {
55
- skipPointerEventsCheck: true
56
- });
57
- this.pointer({
58
- keys: '[MouseLeft][MouseLeft][MouseLeft]',
59
- target: element
60
- });
61
- }
package/dist/hover.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { UserEvent } from './setup';
2
- import { PointerOptions } from './utils';
3
- export declare function hover(this: UserEvent, element: Element, { skipPointerEventsCheck }?: PointerOptions): void;
4
- export declare function unhover(this: UserEvent, element: Element, { skipPointerEventsCheck }?: PointerOptions): void;
package/dist/hover.js DELETED
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.hover = hover;
7
- exports.unhover = unhover;
8
-
9
- var _pointer = require("./pointer");
10
-
11
- var _utils = require("./utils");
12
-
13
- function hover(element, {
14
- skipPointerEventsCheck = false
15
- } = {}) {
16
- if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
17
- throw new Error('unable to hover element as it has or inherits pointer-events set to "none".');
18
- }
19
-
20
- const pointerState = (0, _pointer.createPointerState)();
21
- pointerState.position.mouse.target = element.ownerDocument.body;
22
- this.pointer({
23
- target: element
24
- }, {
25
- pointerState
26
- });
27
- }
28
-
29
- function unhover(element, {
30
- skipPointerEventsCheck = false
31
- } = {}) {
32
- if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
33
- throw new Error('unable to unhover element as it has or inherits pointer-events set to "none".');
34
- }
35
-
36
- const pointerState = (0, _pointer.createPointerState)();
37
- pointerState.position.mouse.target = element;
38
- this.pointer({
39
- target: element.ownerDocument.body
40
- }, {
41
- pointerState
42
- });
43
- }
@@ -1,4 +0,0 @@
1
- import { PointerOptions } from './utils';
2
- import type { UserEvent } from './setup';
3
- export declare function selectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: PointerOptions): void;
4
- export declare function deselectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: PointerOptions): void;
package/dist/setup.d.ts DELETED
@@ -1,100 +0,0 @@
1
- import { clear } from './clear';
2
- import { click, clickOptions, dblClick, tripleClick } from './click';
3
- import { hover, unhover } from './hover';
4
- import { keyboard, keyboardOptions } from './keyboard';
5
- import type { keyboardState } from './keyboard/types';
6
- import { copy, copyOptions, cut, cutOptions, paste, pasteOptions } from './clipboard';
7
- import { pointer } from './pointer';
8
- import type { pointerOptions, pointerState } from './pointer/types';
9
- import { deselectOptions, selectOptions } from './selectOptions';
10
- import { tab, tabOptions } from './tab';
11
- import { type, typeOptions } from './type';
12
- import { upload, uploadOptions } from './upload';
13
- import { PointerOptions } from './utils';
14
- export declare const userEventApis: {
15
- clear: typeof clear;
16
- click: typeof click;
17
- copy: typeof copy;
18
- cut: typeof cut;
19
- dblClick: typeof dblClick;
20
- deselectOptions: typeof deselectOptions;
21
- hover: typeof hover;
22
- keyboard: typeof keyboard;
23
- paste: typeof paste;
24
- pointer: typeof pointer;
25
- selectOptions: typeof selectOptions;
26
- tab: typeof tab;
27
- tripleClick: typeof tripleClick;
28
- type: typeof type;
29
- unhover: typeof unhover;
30
- upload: typeof upload;
31
- };
32
- export declare type UserEventApis = typeof userEventApis;
33
- declare type setup = ReturnType<typeof _setup>['setup'];
34
- export declare type UserEvent = UserEventApis & {
35
- setup: setup;
36
- };
37
- declare type ClickOptions = Omit<clickOptions, 'clickCount'>;
38
- interface ClipboardOptions extends copyOptions, cutOptions, pasteOptions {
39
- }
40
- declare type KeyboardOptions = Partial<keyboardOptions>;
41
- declare type PointerApiOptions = Partial<pointerOptions>;
42
- declare type TabOptions = Omit<tabOptions, 'shift'>;
43
- declare type TypeOptions = Omit<typeOptions, 'initialSelectionStart' | 'initialSelectionEnd'>;
44
- declare type UploadOptions = uploadOptions;
45
- interface SetupOptions extends ClickOptions, ClipboardOptions, KeyboardOptions, PointerOptions, PointerApiOptions, TabOptions, TypeOptions, UploadOptions {
46
- }
47
- /**
48
- * Start a "session" with userEvent.
49
- * All APIs returned by this function share an input device state and a default configuration.
50
- */
51
- export declare function setup(options?: SetupOptions): {
52
- clear: typeof clear;
53
- click: typeof click;
54
- copy: typeof copy;
55
- cut: typeof cut;
56
- dblClick: typeof dblClick;
57
- deselectOptions: typeof deselectOptions;
58
- hover: typeof hover;
59
- keyboard: typeof keyboard;
60
- paste: typeof paste;
61
- pointer: typeof pointer;
62
- selectOptions: typeof selectOptions;
63
- tab: typeof tab;
64
- tripleClick: typeof tripleClick;
65
- type: typeof type;
66
- unhover: typeof unhover;
67
- upload: typeof upload;
68
- } & {
69
- /**
70
- * Create a set of callbacks with different default settings but the same state.
71
- */
72
- setup(options: SetupOptions): {
73
- clear: typeof clear;
74
- click: typeof click;
75
- copy: typeof copy;
76
- cut: typeof cut;
77
- dblClick: typeof dblClick;
78
- deselectOptions: typeof deselectOptions;
79
- hover: typeof hover;
80
- keyboard: typeof keyboard;
81
- paste: typeof paste;
82
- pointer: typeof pointer;
83
- selectOptions: typeof selectOptions;
84
- tab: typeof tab;
85
- tripleClick: typeof tripleClick;
86
- type: typeof type;
87
- unhover: typeof unhover;
88
- upload: typeof upload;
89
- } & any;
90
- };
91
- declare function _setup({ applyAccept, autoModify, delay, document, keyboardMap, pointerMap, skipAutoClose, skipClick, skipHover, skipPointerEventsCheck, writeToClipboard, }: SetupOptions, { keyboardState, pointerState, }: {
92
- keyboardState: keyboardState;
93
- pointerState: pointerState;
94
- }): UserEventApis & {
95
- /**
96
- * Create a set of callbacks with different default settings but the same state.
97
- */
98
- setup(options: SetupOptions): ReturnType<typeof _setup>;
99
- };
100
- export {};
package/dist/setup.js DELETED
@@ -1,241 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.setup = setup;
7
- exports.userEventApis = void 0;
8
-
9
- var _clear = require("./clear");
10
-
11
- var _click = require("./click");
12
-
13
- var _document = require("./document");
14
-
15
- var _hover = require("./hover");
16
-
17
- var _keyboard = require("./keyboard");
18
-
19
- var _clipboard = require("./clipboard");
20
-
21
- var _pointer = require("./pointer");
22
-
23
- var _selectOptions = require("./selectOptions");
24
-
25
- var _tab = require("./tab");
26
-
27
- var _type = require("./type");
28
-
29
- var _upload = require("./upload");
30
-
31
- var _utils = require("./utils");
32
-
33
- const userEventApis = {
34
- clear: _clear.clear,
35
- click: _click.click,
36
- copy: _clipboard.copy,
37
- cut: _clipboard.cut,
38
- dblClick: _click.dblClick,
39
- deselectOptions: _selectOptions.deselectOptions,
40
- hover: _hover.hover,
41
- keyboard: _keyboard.keyboard,
42
- paste: _clipboard.paste,
43
- pointer: _pointer.pointer,
44
- selectOptions: _selectOptions.selectOptions,
45
- tab: _tab.tab,
46
- tripleClick: _click.tripleClick,
47
- type: _type.type,
48
- unhover: _hover.unhover,
49
- upload: _upload.upload
50
- };
51
- exports.userEventApis = userEventApis;
52
-
53
- /**
54
- * Start a "session" with userEvent.
55
- * All APIs returned by this function share an input device state and a default configuration.
56
- */
57
- function setup(options = {}) {
58
- var _options$document, _doc$defaultView;
59
-
60
- const doc = (_options$document = options.document) != null ? _options$document : document;
61
- (0, _document.prepareDocument)(doc);
62
- const view = (_doc$defaultView = doc.defaultView) != null ? _doc$defaultView :
63
- /* istanbul ignore next */
64
- window;
65
- (0, _utils.attachClipboardStubToView)(view);
66
- return _setup(options, {
67
- keyboardState: (0, _keyboard.createKeyboardState)(),
68
- pointerState: (0, _pointer.createPointerState)()
69
- });
70
- }
71
-
72
- function _setup({
73
- applyAccept,
74
- autoModify,
75
- delay = 0,
76
- document,
77
- keyboardMap,
78
- pointerMap,
79
- skipAutoClose,
80
- skipClick,
81
- skipHover,
82
- skipPointerEventsCheck = false,
83
- // Changing default return type from DataTransfer to Promise<DataTransfer>
84
- // would require a lot of overloading right now.
85
- // The APIs returned by setup will most likely be changed to async before stable release anyway.
86
- // See https://github.com/testing-library/user-event/issues/504#issuecomment-944883855
87
- // So the default option can be changed during alpha instead of introducing too much code here.
88
- // TODO: This should default to true
89
- writeToClipboard = false
90
- }, {
91
- keyboardState,
92
- pointerState
93
- }) {
94
- const keyboardDefaults = {
95
- autoModify,
96
- delay,
97
- document,
98
- keyboardMap
99
- };
100
- const pointerDefaults = {
101
- skipPointerEventsCheck
102
- };
103
- const pointerApiDefaults = {
104
- delay,
105
- pointerMap
106
- };
107
- const clickDefaults = {
108
- skipHover
109
- };
110
- const clipboardDefaults = {
111
- document,
112
- writeToClipboard
113
- };
114
- const typeDefaults = {
115
- delay,
116
- skipAutoClose,
117
- skipClick
118
- };
119
- const uploadDefaults = {
120
- applyAccept
121
- };
122
- const userEvent = {
123
- clear: (...args) => {
124
- return _clear.clear.call(userEvent, ...args);
125
- },
126
- click: (...args) => {
127
- args[1] = { ...pointerDefaults,
128
- ...clickDefaults,
129
- ...args[1]
130
- };
131
- return _click.click.call(userEvent, ...args);
132
- },
133
- // copy needs typecasting because of the overloading
134
- copy: (...args) => {
135
- args[0] = { ...clipboardDefaults,
136
- ...args[0]
137
- };
138
- return _clipboard.copy.call(userEvent, ...args);
139
- },
140
- // cut needs typecasting because of the overloading
141
- cut: (...args) => {
142
- args[0] = { ...clipboardDefaults,
143
- ...args[0]
144
- };
145
- return _clipboard.cut.call(userEvent, ...args);
146
- },
147
- dblClick: (...args) => {
148
- args[1] = { ...pointerDefaults,
149
- ...clickDefaults,
150
- ...args[1]
151
- };
152
- return _click.dblClick.call(userEvent, ...args);
153
- },
154
- deselectOptions: (...args) => {
155
- args[2] = { ...pointerDefaults,
156
- ...args[2]
157
- };
158
- return _selectOptions.deselectOptions.call(userEvent, ...args);
159
- },
160
- hover: (...args) => {
161
- args[1] = { ...pointerDefaults,
162
- ...args[1]
163
- };
164
- return _hover.hover.call(userEvent, ...args);
165
- },
166
- // keyboard needs typecasting because of the overloading
167
- keyboard: (...args) => {
168
- args[1] = { ...keyboardDefaults,
169
- ...args[1],
170
- keyboardState
171
- };
172
- const ret = (0, _keyboard.keyboard)(...args);
173
-
174
- if (ret instanceof Promise) {
175
- return ret.then(() => undefined);
176
- }
177
- },
178
- // paste needs typecasting because of the overloading
179
- paste: (...args) => {
180
- args[1] = { ...clipboardDefaults,
181
- ...args[1]
182
- };
183
- return _clipboard.paste.call(userEvent, ...args);
184
- },
185
- // pointer needs typecasting because of the overloading
186
- pointer: (...args) => {
187
- args[1] = { ...pointerApiDefaults,
188
- ...args[1],
189
- pointerState,
190
- keyboardState
191
- };
192
- const ret = (0, _pointer.pointer)(...args);
193
-
194
- if (ret instanceof Promise) {
195
- return ret.then(() => undefined);
196
- }
197
- },
198
- selectOptions: (...args) => {
199
- args[2] = { ...pointerDefaults,
200
- ...args[2]
201
- };
202
- return _selectOptions.selectOptions.call(userEvent, ...args);
203
- },
204
- setup: options => {
205
- return _setup({ ...keyboardDefaults,
206
- ...pointerDefaults,
207
- ...clickDefaults,
208
- ...options
209
- }, {
210
- keyboardState,
211
- pointerState
212
- });
213
- },
214
- tab: (...args) => {
215
- return _tab.tab.call(userEvent, ...args);
216
- },
217
- tripleClick: (...args) => {
218
- return _click.tripleClick.call(userEvent, ...args);
219
- },
220
- // type needs typecasting because of the overloading
221
- type: (...args) => {
222
- args[2] = { ...typeDefaults,
223
- ...args[2]
224
- };
225
- return _type.type.call(userEvent, ...args);
226
- },
227
- unhover: (...args) => {
228
- args[1] = { ...pointerDefaults,
229
- ...args[1]
230
- };
231
- return _hover.unhover.call(userEvent, ...args);
232
- },
233
- upload: (...args) => {
234
- args[3] = { ...uploadDefaults,
235
- ...args[3]
236
- };
237
- return _upload.upload.call(userEvent, ...args);
238
- }
239
- };
240
- return userEvent;
241
- }
package/dist/tab.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { UserEvent } from './setup';
2
- export interface tabOptions {
3
- shift?: boolean;
4
- }
5
- export declare function tab(this: UserEvent, { shift }?: tabOptions): void;
package/dist/tab.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.tab = tab;
7
-
8
- function tab({
9
- shift
10
- } = {}) {
11
- this.keyboard(shift === true ? '{Shift>}{Tab}{/Shift}' : shift === false ? '[/ShiftLeft][/ShiftRight]{Tab}' : '{Tab}');
12
- }
package/dist/type.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { UserEvent } from './setup';
2
- export interface typeOptions {
3
- delay?: number;
4
- skipClick?: boolean;
5
- skipAutoClose?: boolean;
6
- initialSelectionStart?: number;
7
- initialSelectionEnd?: number;
8
- }
9
- export declare function type(this: UserEvent, element: Element, text: string, options?: typeOptions & {
10
- delay?: 0;
11
- }): void;
12
- export declare function type(this: UserEvent, element: Element, text: string, options: typeOptions & {
13
- delay: number;
14
- }): Promise<void>;