@testing-library/user-event 14.0.0-alpha.7 → 14.0.0-beta.2
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.
- package/dist/clipboard/copy.d.ts +2 -0
- package/dist/clipboard/copy.js +36 -0
- package/dist/clipboard/cut.d.ts +2 -0
- package/dist/clipboard/cut.js +42 -0
- package/dist/clipboard/index.d.ts +3 -0
- package/dist/clipboard/index.js +44 -0
- package/dist/clipboard/paste.d.ts +2 -0
- package/dist/clipboard/paste.js +47 -0
- package/dist/convenience/click.d.ts +4 -0
- package/dist/convenience/click.js +52 -0
- package/dist/convenience/hover.d.ts +3 -0
- package/dist/convenience/hover.js +31 -0
- package/dist/convenience/index.d.ts +3 -0
- package/dist/convenience/index.js +44 -0
- package/dist/convenience/tab.d.ts +4 -0
- package/dist/convenience/tab.js +12 -0
- package/dist/index.d.ts +2 -7
- package/dist/index.js +3 -12
- package/dist/keyboard/getEventProps.d.ts +0 -2
- package/dist/keyboard/getEventProps.js +1 -7
- package/dist/keyboard/index.d.ts +6 -18
- package/dist/keyboard/index.js +9 -45
- package/dist/keyboard/keyMap.js +24 -48
- package/dist/keyboard/keyboardAction.d.ts +10 -0
- package/dist/keyboard/keyboardAction.js +156 -0
- package/dist/keyboard/{getNextKeyDef.d.ts → parseKeyDef.d.ts} +4 -6
- package/dist/keyboard/parseKeyDef.js +61 -0
- package/dist/keyboard/plugins/character.js +21 -14
- package/dist/keyboard/plugins/combination.d.ts +5 -0
- package/dist/keyboard/plugins/combination.js +19 -0
- package/dist/keyboard/plugins/functional.js +38 -20
- package/dist/keyboard/plugins/index.d.ts +0 -1
- package/dist/keyboard/plugins/index.js +4 -11
- package/dist/keyboard/types.d.ts +3 -19
- package/dist/options.d.ts +102 -0
- package/dist/options.js +36 -0
- package/dist/pointer/index.d.ts +6 -14
- package/dist/pointer/index.js +8 -42
- package/dist/pointer/parseKeyDef.d.ts +2 -2
- package/dist/pointer/parseKeyDef.js +1 -3
- package/dist/pointer/pointerAction.d.ts +3 -2
- package/dist/pointer/pointerAction.js +9 -15
- package/dist/pointer/pointerMove.d.ts +2 -1
- package/dist/pointer/pointerPress.d.ts +2 -1
- package/dist/pointer/types.d.ts +0 -11
- package/dist/setup/api.d.ts +5 -0
- package/dist/setup/api.js +111 -0
- package/dist/setup/config.d.ts +10 -0
- package/dist/setup/config.js +8 -0
- package/dist/setup/directApi.d.ts +20 -0
- package/dist/setup/directApi.js +95 -0
- package/dist/setup/index.d.ts +30 -0
- package/dist/setup/index.js +27 -0
- package/dist/setup/setup.d.ts +74 -0
- package/dist/setup/setup.js +98 -0
- package/dist/setup/wrapAsync.d.ts +4 -0
- package/dist/setup/wrapAsync.js +15 -0
- package/dist/{clear.d.ts → utility/clear.d.ts} +2 -2
- package/dist/utility/clear.js +30 -0
- package/dist/utility/index.d.ts +4 -0
- package/dist/utility/index.js +57 -0
- package/dist/utility/selectOptions.d.ts +3 -0
- package/dist/{selectOptions.js → utility/selectOptions.js} +31 -41
- package/dist/utility/type.d.ts +9 -0
- package/dist/utility/type.js +37 -0
- package/dist/utility/upload.d.ts +5 -0
- package/dist/{upload.js → utility/upload.js} +12 -40
- package/dist/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/utils/dataTransfer/Blob.js +21 -0
- package/dist/utils/dataTransfer/Clipboard.d.ts +9 -0
- package/dist/utils/dataTransfer/Clipboard.js +188 -0
- package/dist/utils/dataTransfer/DataTransfer.d.ts +2 -0
- package/dist/utils/dataTransfer/DataTransfer.js +158 -0
- package/dist/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/utils/dataTransfer/FileList.js +23 -0
- package/dist/utils/edit/calculateNewValue.d.ts +1 -3
- package/dist/utils/edit/calculateNewValue.js +1 -5
- package/dist/utils/edit/editInputElement.d.ts +16 -0
- package/dist/utils/edit/{fireInputEvent.js → editInputElement.js} +8 -20
- package/dist/utils/edit/prepareInput.d.ts +4 -1
- package/dist/utils/edit/prepareInput.js +56 -39
- package/dist/utils/edit/setFiles.d.ts +12 -0
- package/dist/utils/edit/setFiles.js +72 -0
- package/dist/utils/focus/copySelection.d.ts +1 -0
- package/dist/utils/focus/copySelection.js +36 -0
- package/dist/utils/focus/selectAll.d.ts +5 -0
- package/dist/utils/focus/selectAll.js +51 -0
- package/dist/utils/index.d.ts +9 -2
- package/dist/utils/index.js +108 -17
- package/dist/utils/misc/getDocumentFromNode.d.ts +1 -0
- package/dist/utils/misc/getDocumentFromNode.js +14 -0
- package/dist/utils/misc/isVisible.js +8 -1
- package/dist/utils/pointer/firePointerEvents.d.ts +12 -1
- package/dist/utils/pointer/firePointerEvents.js +62 -5
- package/package.json +1 -1
- package/dist/clear.js +0 -46
- package/dist/click.d.ts +0 -9
- package/dist/click.js +0 -62
- package/dist/hover.d.ts +0 -4
- package/dist/hover.js +0 -43
- package/dist/keyboard/getNextKeyDef.js +0 -85
- package/dist/keyboard/keyboardImplementation.d.ts +0 -3
- package/dist/keyboard/keyboardImplementation.js +0 -169
- package/dist/keyboard/specialCharMap.d.ts +0 -22
- package/dist/keyboard/specialCharMap.js +0 -30
- package/dist/paste.d.ts +0 -7
- package/dist/paste.js +0 -60
- package/dist/selectOptions.d.ts +0 -4
- package/dist/setup.d.ts +0 -92
- package/dist/setup.js +0 -203
- package/dist/tab.d.ts +0 -5
- package/dist/tab.js +0 -12
- package/dist/type.d.ts +0 -14
- package/dist/type.js +0 -74
- package/dist/upload.d.ts +0 -10
- package/dist/utils/edit/fireInputEvent.d.ts +0 -11
- package/dist/utils/pointer/fakeEvent.d.ts +0 -20
- package/dist/utils/pointer/fakeEvent.js +0 -91
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>;
|
package/dist/type.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.type = type;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _document = require("./document");
|
|
11
|
-
|
|
12
|
-
var _utils = require("./utils");
|
|
13
|
-
|
|
14
|
-
var _keyboard = require("./keyboard");
|
|
15
|
-
|
|
16
|
-
// this needs to be wrapped in the event/asyncWrapper for React's act and angular's change detection
|
|
17
|
-
// depending on whether it will be async.
|
|
18
|
-
function type(element, text, {
|
|
19
|
-
delay = 0,
|
|
20
|
-
...options
|
|
21
|
-
} = {}) {
|
|
22
|
-
(0, _document.prepareDocument)(element.ownerDocument); // we do not want to wrap in the asyncWrapper if we're not
|
|
23
|
-
// going to actually be doing anything async, so we only wrap
|
|
24
|
-
// if the delay is greater than 0
|
|
25
|
-
|
|
26
|
-
if (delay > 0) {
|
|
27
|
-
return (0, _dom.getConfig)().asyncWrapper(() => typeImplementation(this, element, text, {
|
|
28
|
-
delay,
|
|
29
|
-
...options
|
|
30
|
-
}));
|
|
31
|
-
} else {
|
|
32
|
-
return void typeImplementation(this, element, text, {
|
|
33
|
-
delay,
|
|
34
|
-
...options
|
|
35
|
-
}) // prevents users from dealing with UnhandledPromiseRejectionWarning
|
|
36
|
-
.catch(console.error);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function typeImplementation(userEvent, element, text, {
|
|
41
|
-
delay,
|
|
42
|
-
skipClick = false,
|
|
43
|
-
skipAutoClose = false,
|
|
44
|
-
initialSelectionStart = undefined,
|
|
45
|
-
initialSelectionEnd = undefined
|
|
46
|
-
}) {
|
|
47
|
-
// TODO: properly type guard
|
|
48
|
-
// we use this workaround for now to prevent changing behavior
|
|
49
|
-
if (element.disabled) return;
|
|
50
|
-
if (!skipClick) userEvent.click(element);
|
|
51
|
-
|
|
52
|
-
if (initialSelectionStart !== undefined) {
|
|
53
|
-
(0, _utils.setSelectionRange)(element, initialSelectionStart, initialSelectionEnd != null ? initialSelectionEnd : initialSelectionStart);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const {
|
|
57
|
-
promise,
|
|
58
|
-
releaseAllKeys
|
|
59
|
-
} = (0, _keyboard.keyboardImplementationWrapper)(text, {
|
|
60
|
-
delay,
|
|
61
|
-
document: element.ownerDocument
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
if (delay > 0) {
|
|
65
|
-
await promise;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (!skipAutoClose) {
|
|
69
|
-
releaseAllKeys();
|
|
70
|
-
} // eslint-disable-next-line consistent-return -- we need to return the internal Promise so that it is catchable if we don't await
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return promise;
|
|
74
|
-
}
|
package/dist/upload.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { UserEvent } from './setup';
|
|
2
|
-
interface uploadInit {
|
|
3
|
-
clickInit?: MouseEventInit;
|
|
4
|
-
changeInit?: EventInit;
|
|
5
|
-
}
|
|
6
|
-
export interface uploadOptions {
|
|
7
|
-
applyAccept?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare function upload(this: UserEvent, element: HTMLElement, fileOrFiles: File | File[], init?: uploadInit, { applyAccept }?: uploadOptions): void;
|
|
10
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { fireEvent } from '@testing-library/dom';
|
|
2
|
-
export declare function fireInputEvent(element: HTMLElement, { newValue, newSelection, eventOverrides, }: {
|
|
3
|
-
newValue: string;
|
|
4
|
-
newSelection: {
|
|
5
|
-
node: Node;
|
|
6
|
-
offset: number;
|
|
7
|
-
};
|
|
8
|
-
eventOverrides: Partial<Parameters<typeof fireEvent>[1]> & {
|
|
9
|
-
[k: string]: unknown;
|
|
10
|
-
};
|
|
11
|
-
}): void;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface PointerCoords {
|
|
2
|
-
x?: number;
|
|
3
|
-
y?: number;
|
|
4
|
-
clientX?: number;
|
|
5
|
-
clientY?: number;
|
|
6
|
-
offsetX?: number;
|
|
7
|
-
offsetY?: number;
|
|
8
|
-
pageX?: number;
|
|
9
|
-
pageY?: number;
|
|
10
|
-
screenX?: number;
|
|
11
|
-
screenY?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface FakePointerEventInit extends MouseEventInit, PointerEventInit, PointerCoords {
|
|
14
|
-
}
|
|
15
|
-
export declare class FakeMouseEvent extends MouseEvent {
|
|
16
|
-
constructor(type: string, init: FakePointerEventInit);
|
|
17
|
-
}
|
|
18
|
-
export declare class FakePointerEvent extends MouseEvent {
|
|
19
|
-
constructor(type: string, init: FakePointerEventInit);
|
|
20
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.FakePointerEvent = exports.FakeMouseEvent = void 0;
|
|
7
|
-
|
|
8
|
-
// See : https://github.com/testing-library/react-testing-library/issues/268
|
|
9
|
-
function assignProps(obj, props) {
|
|
10
|
-
for (const [key, value] of Object.entries(props)) {
|
|
11
|
-
Object.defineProperty(obj, key, {
|
|
12
|
-
get: () => value
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function assignPositionInit(obj, {
|
|
18
|
-
x,
|
|
19
|
-
y,
|
|
20
|
-
clientX,
|
|
21
|
-
clientY,
|
|
22
|
-
offsetX,
|
|
23
|
-
offsetY,
|
|
24
|
-
pageX,
|
|
25
|
-
pageY,
|
|
26
|
-
screenX,
|
|
27
|
-
screenY
|
|
28
|
-
}) {
|
|
29
|
-
var _ref, _ref2, _ref3, _ref4;
|
|
30
|
-
|
|
31
|
-
assignProps(obj, {
|
|
32
|
-
/* istanbul ignore start */
|
|
33
|
-
x: (_ref = x != null ? x : clientX) != null ? _ref : 0,
|
|
34
|
-
y: (_ref2 = y != null ? y : clientY) != null ? _ref2 : 0,
|
|
35
|
-
clientX: (_ref3 = x != null ? x : clientX) != null ? _ref3 : 0,
|
|
36
|
-
clientY: (_ref4 = y != null ? y : clientY) != null ? _ref4 : 0,
|
|
37
|
-
offsetX: offsetX != null ? offsetX : 0,
|
|
38
|
-
offsetY: offsetY != null ? offsetY : 0,
|
|
39
|
-
pageX: pageX != null ? pageX : 0,
|
|
40
|
-
pageY: pageY != null ? pageY : 0,
|
|
41
|
-
screenX: screenX != null ? screenX : 0,
|
|
42
|
-
screenY: screenY != null ? screenY : 0
|
|
43
|
-
/* istanbul ignore end */
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function assignPointerInit(obj, {
|
|
49
|
-
isPrimary,
|
|
50
|
-
pointerId,
|
|
51
|
-
pointerType
|
|
52
|
-
}) {
|
|
53
|
-
assignProps(obj, {
|
|
54
|
-
isPrimary,
|
|
55
|
-
pointerId,
|
|
56
|
-
pointerType
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const notBubbling = ['mouseenter', 'mouseleave', 'pointerenter', 'pointerleave'];
|
|
61
|
-
|
|
62
|
-
function getInitDefaults(type, init) {
|
|
63
|
-
return {
|
|
64
|
-
bubbles: !notBubbling.includes(type),
|
|
65
|
-
cancelable: true,
|
|
66
|
-
composed: true,
|
|
67
|
-
...init
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
class FakeMouseEvent extends MouseEvent {
|
|
72
|
-
constructor(type, init) {
|
|
73
|
-
super(type, getInitDefaults(type, init));
|
|
74
|
-
assignPositionInit(this, init);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
} // Should extend PointerEvent, but... https://github.com/jsdom/jsdom/issues/2527
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
exports.FakeMouseEvent = FakeMouseEvent;
|
|
81
|
-
|
|
82
|
-
class FakePointerEvent extends MouseEvent {
|
|
83
|
-
constructor(type, init) {
|
|
84
|
-
super(type, getInitDefaults(type, init));
|
|
85
|
-
assignPositionInit(this, init);
|
|
86
|
-
assignPointerInit(this, init);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
exports.FakePointerEvent = FakePointerEvent;
|