@testing-library/user-event 14.4.3 → 14.5.1
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/cjs/_interop/dtl.js +27 -0
- package/dist/cjs/_interop/dtlEventMap.js +27 -0
- package/dist/cjs/_interop/dtlHelpers.js +27 -0
- package/dist/cjs/clipboard/copy.js +2 -2
- package/dist/cjs/clipboard/cut.js +2 -2
- package/dist/cjs/clipboard/paste.js +4 -4
- package/dist/cjs/convenience/tab.js +1 -1
- package/dist/cjs/document/UI.js +5 -5
- package/dist/cjs/document/interceptor.js +1 -1
- package/dist/cjs/document/trackValue.js +4 -4
- package/dist/cjs/event/behavior/keydown.js +6 -6
- package/dist/cjs/event/behavior/keypress.js +2 -2
- package/dist/cjs/event/behavior/keyup.js +2 -2
- package/dist/cjs/event/behavior/paste.js +2 -2
- package/dist/cjs/event/createEvent.js +41 -41
- package/dist/cjs/event/dispatchEvent.js +2 -2
- package/dist/cjs/event/eventMap.js +22 -2
- package/dist/cjs/event/focus.js +1 -4
- package/dist/cjs/event/input.js +4 -4
- package/dist/cjs/event/selection/getInputRange.js +2 -2
- package/dist/cjs/event/selection/modifySelection.js +3 -3
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +1 -1
- package/dist/cjs/event/selection/moveSelection.js +5 -5
- package/dist/cjs/event/selection/resolveCaretPosition.js +1 -1
- package/dist/cjs/event/selection/selectAll.js +4 -4
- package/dist/cjs/event/selection/setSelection.js +3 -3
- package/dist/cjs/event/selection/setSelectionPerMouse.js +5 -5
- package/dist/cjs/event/selection/setSelectionRange.js +2 -2
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +2 -2
- package/dist/cjs/event/wrapEvent.js +23 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/keyboard/index.js +2 -2
- package/dist/cjs/keyboard/parseKeyDef.js +8 -8
- package/dist/cjs/pointer/index.js +11 -11
- package/dist/cjs/pointer/keyMap.js +1 -1
- package/dist/cjs/pointer/parseKeyDef.js +1 -1
- package/dist/cjs/setup/api.js +19 -17
- package/dist/cjs/setup/directApi.js +3 -3
- package/dist/cjs/setup/setup.js +10 -10
- package/dist/cjs/setup/wrapAsync.js +23 -2
- package/dist/cjs/system/index.js +15 -2
- package/dist/cjs/system/keyboard.js +27 -12
- package/dist/cjs/system/pointer/buttons.js +14 -1
- package/dist/cjs/system/pointer/device.js +14 -1
- package/dist/cjs/system/pointer/index.js +34 -17
- package/dist/cjs/system/pointer/mouse.js +33 -19
- package/dist/cjs/system/pointer/pointer.js +24 -8
- package/dist/cjs/system/pointer/shared.js +2 -2
- package/dist/cjs/utility/selectOptions.js +32 -11
- package/dist/cjs/utility/type.js +1 -1
- package/dist/cjs/utility/upload.js +4 -4
- package/dist/cjs/utils/dataTransfer/Clipboard.js +22 -8
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +23 -8
- package/dist/cjs/utils/edit/maxLength.js +2 -2
- package/dist/cjs/utils/edit/setFiles.js +4 -4
- package/dist/cjs/utils/focus/cursor.js +2 -2
- package/dist/cjs/utils/focus/getActiveElement.js +2 -2
- package/dist/cjs/utils/focus/selector.js +1 -1
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
- package/dist/cjs/utils/misc/getWindow.js +23 -2
- package/dist/cjs/utils/misc/isDisabled.js +3 -3
- package/dist/cjs/utils/misc/isVisible.js +1 -1
- package/dist/cjs/utils/misc/wait.js +1 -1
- package/dist/cjs/utils/pointer/cssPointerEvents.js +13 -13
- package/dist/esm/_interop/dtl.js +2 -0
- package/dist/esm/_interop/dtlEventMap.js +2 -0
- package/dist/esm/_interop/dtlHelpers.js +2 -0
- package/dist/esm/clipboard/copy.js +2 -2
- package/dist/esm/clipboard/cut.js +2 -2
- package/dist/esm/clipboard/paste.js +4 -4
- package/dist/esm/convenience/tab.js +1 -1
- package/dist/esm/document/UI.js +5 -5
- package/dist/esm/document/interceptor.js +1 -1
- package/dist/esm/document/trackValue.js +4 -4
- package/dist/esm/event/behavior/keydown.js +6 -6
- package/dist/esm/event/behavior/keypress.js +2 -2
- package/dist/esm/event/behavior/keyup.js +2 -2
- package/dist/esm/event/behavior/paste.js +2 -2
- package/dist/esm/event/createEvent.js +41 -41
- package/dist/esm/event/dispatchEvent.js +2 -2
- package/dist/esm/event/eventMap.js +2 -2
- package/dist/esm/event/focus.js +1 -4
- package/dist/esm/event/input.js +4 -4
- package/dist/esm/event/selection/getInputRange.js +2 -2
- package/dist/esm/event/selection/modifySelection.js +3 -3
- package/dist/esm/event/selection/modifySelectionPerMouse.js +1 -1
- package/dist/esm/event/selection/moveSelection.js +5 -5
- package/dist/esm/event/selection/resolveCaretPosition.js +1 -1
- package/dist/esm/event/selection/selectAll.js +4 -4
- package/dist/esm/event/selection/setSelection.js +3 -3
- package/dist/esm/event/selection/setSelectionPerMouse.js +5 -5
- package/dist/esm/event/selection/setSelectionRange.js +2 -2
- package/dist/esm/event/selection/updateSelectionOnFocus.js +2 -2
- package/dist/esm/event/wrapEvent.js +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/keyboard/index.js +2 -2
- package/dist/esm/keyboard/parseKeyDef.js +8 -8
- package/dist/esm/pointer/index.js +11 -11
- package/dist/esm/pointer/keyMap.js +1 -1
- package/dist/esm/pointer/parseKeyDef.js +1 -1
- package/dist/esm/setup/api.js +33 -12
- package/dist/esm/setup/directApi.js +3 -3
- package/dist/esm/setup/setup.js +11 -11
- package/dist/esm/setup/wrapAsync.js +2 -1
- package/dist/esm/system/index.js +15 -2
- package/dist/esm/system/keyboard.js +27 -12
- package/dist/esm/system/pointer/buttons.js +14 -1
- package/dist/esm/system/pointer/device.js +14 -1
- package/dist/esm/system/pointer/index.js +34 -17
- package/dist/esm/system/pointer/mouse.js +33 -19
- package/dist/esm/system/pointer/pointer.js +24 -8
- package/dist/esm/system/pointer/shared.js +2 -2
- package/dist/esm/utility/selectOptions.js +8 -7
- package/dist/esm/utility/type.js +1 -1
- package/dist/esm/utility/upload.js +4 -4
- package/dist/esm/utils/dataTransfer/Clipboard.js +22 -8
- package/dist/esm/utils/dataTransfer/DataTransfer.js +23 -8
- package/dist/esm/utils/edit/maxLength.js +2 -2
- package/dist/esm/utils/edit/setFiles.js +4 -4
- package/dist/esm/utils/focus/cursor.js +2 -2
- package/dist/esm/utils/focus/getActiveElement.js +2 -2
- package/dist/esm/utils/focus/selector.js +1 -1
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/esm/utils/misc/getTreeDiff.js +3 -3
- package/dist/esm/utils/misc/getWindow.js +2 -1
- package/dist/esm/utils/misc/isDisabled.js +3 -3
- package/dist/esm/utils/misc/isVisible.js +1 -1
- package/dist/esm/utils/misc/wait.js +1 -1
- package/dist/esm/utils/pointer/cssPointerEvents.js +13 -13
- package/dist/types/_interop/dtl.d.ts +2 -0
- package/dist/types/_interop/dtlEventMap.d.ts +2 -0
- package/dist/types/_interop/dtlHelpers.d.ts +2 -0
- package/dist/types/clipboard/copy.d.ts +1 -1
- package/dist/types/clipboard/cut.d.ts +1 -1
- package/dist/types/clipboard/paste.d.ts +1 -1
- package/dist/types/convenience/click.d.ts +1 -1
- package/dist/types/convenience/hover.d.ts +1 -1
- package/dist/types/convenience/tab.d.ts +1 -1
- package/dist/types/document/UI.d.ts +3 -3
- package/dist/types/document/interceptor.d.ts +3 -3
- package/dist/types/event/behavior/registry.d.ts +1 -1
- package/dist/types/event/createEvent.d.ts +1 -1
- package/dist/types/event/dispatchEvent.d.ts +1 -1
- package/dist/types/event/eventMap.d.ts +8 -0
- package/dist/types/event/input.d.ts +1 -1
- package/dist/types/event/radio.d.ts +1 -1
- package/dist/types/event/selection/index.d.ts +2 -2
- package/dist/types/event/selection/modifySelectionPerMouse.d.ts +1 -1
- package/dist/types/event/selection/setSelectionPerMouse.d.ts +1 -1
- package/dist/types/event/types.d.ts +3 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/keyboard/index.d.ts +1 -1
- package/dist/types/options.d.ts +2 -2
- package/dist/types/pointer/index.d.ts +7 -7
- package/dist/types/setup/api.d.ts +23 -5
- package/dist/types/setup/directApi.d.ts +5 -5
- package/dist/types/setup/setup.d.ts +5 -5
- package/dist/types/system/keyboard.d.ts +2 -2
- package/dist/types/system/pointer/buttons.d.ts +2 -2
- package/dist/types/system/pointer/device.d.ts +1 -1
- package/dist/types/system/pointer/mouse.d.ts +2 -2
- package/dist/types/system/pointer/pointer.d.ts +2 -2
- package/dist/types/utility/clear.d.ts +1 -1
- package/dist/types/utility/selectOptions.d.ts +1 -1
- package/dist/types/utility/type.d.ts +2 -2
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +1 -1
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
- package/dist/types/utils/edit/isEditable.d.ts +2 -2
- package/dist/types/utils/edit/maxLength.d.ts +1 -1
- package/dist/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
- package/dist/types/utils/misc/isElementType.d.ts +1 -1
- package/dist/types/utils/misc/level.d.ts +2 -2
- package/dist/types/utils/misc/wait.d.ts +1 -1
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +1 -1
- package/package.json +22 -11
- /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
|
@@ -4,8 +4,8 @@ import { isElementType } from '../misc/isElementType.js';
|
|
|
4
4
|
import { ApiLevel, getLevelRef } from '../misc/level.js';
|
|
5
5
|
|
|
6
6
|
function hasPointerEvents(instance, element) {
|
|
7
|
-
var
|
|
8
|
-
return ((
|
|
7
|
+
var _checkPointerEvents;
|
|
8
|
+
return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === void 0 ? void 0 : _checkPointerEvents.pointerEvents) !== 'none';
|
|
9
9
|
}
|
|
10
10
|
function closestPointerEventsDeclaration(element) {
|
|
11
11
|
const window = getWindow(element);
|
|
@@ -45,7 +45,7 @@ function assertPointerEvents(instance, element) {
|
|
|
45
45
|
throw new Error([
|
|
46
46
|
`Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
|
|
47
47
|
'',
|
|
48
|
-
printTree(declaration.tree)
|
|
48
|
+
printTree(declaration.tree)
|
|
49
49
|
].join('\n'));
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -57,17 +57,17 @@ function printTree(tree) {
|
|
|
57
57
|
el.hasAttribute('data-testid') && `(testId=${el.getAttribute('data-testid')})`,
|
|
58
58
|
getLabelDescr(el),
|
|
59
59
|
tree.length > 1 && i === 0 && ' <-- This element declared `pointer-events: none`',
|
|
60
|
-
tree.length > 1 && i === tree.length - 1 && ' <-- Asserted pointer events here'
|
|
60
|
+
tree.length > 1 && i === tree.length - 1 && ' <-- Asserted pointer events here'
|
|
61
61
|
].filter(Boolean).join('')).join('\n');
|
|
62
62
|
}
|
|
63
63
|
function getLabelDescr(element) {
|
|
64
|
-
var
|
|
64
|
+
var _element_labels;
|
|
65
65
|
let label;
|
|
66
66
|
if (element.hasAttribute('aria-label')) {
|
|
67
67
|
label = element.getAttribute('aria-label');
|
|
68
68
|
} else if (element.hasAttribute('aria-labelledby')) {
|
|
69
|
-
var
|
|
70
|
-
label = (
|
|
69
|
+
var _element_ownerDocument_getElementById_textContent, _element_ownerDocument_getElementById;
|
|
70
|
+
label = (_element_ownerDocument_getElementById = element.ownerDocument.getElementById(element.getAttribute('aria-labelledby'))) === null || _element_ownerDocument_getElementById === void 0 ? void 0 : (_element_ownerDocument_getElementById_textContent = _element_ownerDocument_getElementById.textContent) === null || _element_ownerDocument_getElementById_textContent === void 0 ? void 0 : _element_ownerDocument_getElementById_textContent.trim();
|
|
71
71
|
} else if (isElementType(element, [
|
|
72
72
|
'button',
|
|
73
73
|
'input',
|
|
@@ -75,15 +75,15 @@ function getLabelDescr(element) {
|
|
|
75
75
|
'output',
|
|
76
76
|
'progress',
|
|
77
77
|
'select',
|
|
78
|
-
'textarea'
|
|
79
|
-
]) && ((
|
|
78
|
+
'textarea'
|
|
79
|
+
]) && ((_element_labels = element.labels) === null || _element_labels === void 0 ? void 0 : _element_labels.length)) {
|
|
80
80
|
label = Array.from(element.labels).map((el)=>{
|
|
81
|
-
var
|
|
82
|
-
return (
|
|
81
|
+
var _el_textContent;
|
|
82
|
+
return (_el_textContent = el.textContent) === null || _el_textContent === void 0 ? void 0 : _el_textContent.trim();
|
|
83
83
|
}).join('|');
|
|
84
84
|
} else if (isElementType(element, 'button')) {
|
|
85
|
-
var
|
|
86
|
-
label = (
|
|
85
|
+
var _element_textContent;
|
|
86
|
+
label = (_element_textContent = element.textContent) === null || _element_textContent === void 0 ? void 0 : _element_textContent.trim();
|
|
87
87
|
}
|
|
88
88
|
label = label === null || label === void 0 ? void 0 : label.replace(/\n/g, ' ');
|
|
89
89
|
if (Number(label === null || label === void 0 ? void 0 : label.length) > 30) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
export declare function copy(this: Instance): Promise<DataTransfer | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
export declare function cut(this: Instance): Promise<DataTransfer | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
export declare function paste(this: Instance, clipboardData?: DataTransfer | string): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
export declare function click(this: Instance, element: Element): Promise<void>;
|
|
3
3
|
export declare function dblClick(this: Instance, element: Element): Promise<void>;
|
|
4
4
|
export declare function tripleClick(this: Instance, element: Element): Promise<void>;
|
|
@@ -12,10 +12,10 @@ interface UISelection {
|
|
|
12
12
|
anchorOffset: number;
|
|
13
13
|
focusOffset: number;
|
|
14
14
|
}
|
|
15
|
-
export
|
|
15
|
+
export type UIValueString = String & {
|
|
16
16
|
[UIValue]: true;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type UISelectionStart = Number & {
|
|
19
19
|
[UISelection]: true;
|
|
20
20
|
};
|
|
21
21
|
export declare function isUIValue(value: string | UIValueString): value is UIValueString;
|
|
@@ -31,7 +31,7 @@ export declare function setUISelection(element: HTMLInputElement | HTMLTextAreaE
|
|
|
31
31
|
anchorOffset?: number;
|
|
32
32
|
focusOffset: number;
|
|
33
33
|
}, mode?: 'replace' | 'modify'): void;
|
|
34
|
-
export
|
|
34
|
+
export type UISelectionRange = UISelection & {
|
|
35
35
|
startOffset: number;
|
|
36
36
|
endOffset: number;
|
|
37
37
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type anyFunc = (...a: any[]) => any;
|
|
2
|
+
type Params<Prop> = Prop extends anyFunc ? Parameters<Prop> : [Prop];
|
|
3
|
+
type ImplReturn<Prop> = Prop extends anyFunc ? Parameters<Prop> : Prop;
|
|
4
4
|
export declare function prepareInterceptor<ElementType extends Element, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => {
|
|
5
5
|
/**
|
|
6
6
|
* React tracks the changes on element properties.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
2
|
import { EventType } from '../types';
|
|
3
3
|
export interface BehaviorPlugin<Type extends EventType> {
|
|
4
4
|
(event: DocumentEventMap[Type], target: Element, instance: Instance): // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EventType, type EventTypeInit, type FixedDocumentEventMap } from './types';
|
|
2
2
|
export declare function createEvent<K extends EventType>(type: K, target: Element, init?: EventTypeInit<K>): FixedDocumentEventMap[K];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
import { EventType, EventTypeInit } from './types';
|
|
3
3
|
export declare function dispatchUIEvent<K extends EventType>(this: Instance, target: Element, type: K, init?: EventTypeInit<K>, preventDefault?: boolean): boolean;
|
|
4
4
|
export declare function dispatchEvent(this: Instance, target: Element, event: Event, preventDefault?: boolean): boolean;
|
|
@@ -376,6 +376,14 @@ export declare const eventMap: {
|
|
|
376
376
|
EventType: EventInterface;
|
|
377
377
|
defaultInit: EventInit;
|
|
378
378
|
};
|
|
379
|
+
readonly offline: {
|
|
380
|
+
EventType: EventInterface;
|
|
381
|
+
defaultInit: EventInit;
|
|
382
|
+
};
|
|
383
|
+
readonly online: {
|
|
384
|
+
EventType: EventInterface;
|
|
385
|
+
defaultInit: EventInit;
|
|
386
|
+
};
|
|
379
387
|
};
|
|
380
388
|
export declare const eventMapKeys: {
|
|
381
389
|
[k in keyof DocumentEventMap]?: keyof typeof eventMap;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
export declare function input(instance: Instance, element: Element, data: string, inputType?: string): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EditableInputOrTextarea } from '../../utils';
|
|
2
2
|
export { getInputRange } from './getInputRange';
|
|
3
3
|
export { modifySelection } from './modifySelection';
|
|
4
4
|
export { moveSelection } from './moveSelection';
|
|
@@ -8,7 +8,7 @@ export { isAllSelected, selectAll } from './selectAll';
|
|
|
8
8
|
export { setSelectionRange } from './setSelectionRange';
|
|
9
9
|
export { setSelection } from './setSelection';
|
|
10
10
|
export { updateSelectionOnFocus } from './updateSelectionOnFocus';
|
|
11
|
-
export
|
|
11
|
+
export type SelectionRange = {
|
|
12
12
|
node: EditableInputOrTextarea;
|
|
13
13
|
start: number;
|
|
14
14
|
end: number;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type EventType = keyof DocumentEventMap;
|
|
2
|
+
export type EventTypeInit<K extends EventType> = SpecificEventInit<FixedDocumentEventMap[K]>;
|
|
3
3
|
export interface FixedDocumentEventMap extends DocumentEventMap {
|
|
4
4
|
input: InputEvent;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
type SpecificEventInit<E extends Event> = E extends InputEvent ? InputEventInit : E extends ClipboardEvent ? ClipboardEventInit : E extends KeyboardEvent ? KeyboardEventInit : E extends PointerEvent ? PointerEventInit : E extends MouseEvent ? MouseEventInit : E extends UIEvent ? UIEventInit : EventInit;
|
|
7
7
|
export interface PointerCoords {
|
|
8
8
|
x?: number;
|
|
9
9
|
y?: number;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { userEvent as default } from './setup';
|
|
2
|
+
export { userEvent } from './setup';
|
|
3
|
+
export type { UserEvent } from './setup/setup';
|
|
2
4
|
export type { keyboardKey } from './system/keyboard';
|
|
3
5
|
export type { pointerKey } from './system/pointer';
|
|
4
|
-
export { PointerEventsCheckLevel } from './options';
|
|
6
|
+
export { PointerEventsCheckLevel, type Options } from './options';
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type keyboardKey } from './system/keyboard';
|
|
2
|
+
import { type pointerKey } from './system/pointer';
|
|
3
3
|
export declare enum PointerEventsCheckLevel {
|
|
4
4
|
/**
|
|
5
5
|
* Check pointer events on every user interaction that triggers a bunch of events.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
|
|
1
|
+
import { type PointerCoords } from '../event';
|
|
2
|
+
import { type Instance } from '../setup';
|
|
3
|
+
import { type pointerKey } from '../system/pointer';
|
|
4
|
+
type PointerActionInput = string | ({
|
|
5
5
|
keys: string;
|
|
6
6
|
} & PointerActionPosition) | PointerAction;
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type PointerInput = PointerActionInput | Array<PointerActionInput>;
|
|
8
|
+
type PointerAction = PointerPressAction | PointerMoveAction;
|
|
9
|
+
type PointerActionPosition = {
|
|
10
10
|
target?: Element;
|
|
11
11
|
coords?: PointerCoords;
|
|
12
12
|
node?: Node;
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { click, dblClick, tripleClick, hover, unhover, tab } from '../convenience';
|
|
2
|
+
import { keyboard } from '../keyboard';
|
|
3
|
+
import { copy, cut, paste } from '../clipboard';
|
|
4
|
+
import { pointer } from '../pointer';
|
|
5
|
+
import { clear, deselectOptions, selectOptions, type, upload } from '../utility';
|
|
6
|
+
export declare const userEventApi: {
|
|
7
|
+
click: typeof click;
|
|
8
|
+
dblClick: typeof dblClick;
|
|
9
|
+
tripleClick: typeof tripleClick;
|
|
10
|
+
hover: typeof hover;
|
|
11
|
+
unhover: typeof unhover;
|
|
12
|
+
tab: typeof tab;
|
|
13
|
+
keyboard: typeof keyboard;
|
|
14
|
+
copy: typeof copy;
|
|
15
|
+
cut: typeof cut;
|
|
16
|
+
paste: typeof paste;
|
|
17
|
+
pointer: typeof pointer;
|
|
18
|
+
clear: typeof clear;
|
|
19
|
+
deselectOptions: typeof deselectOptions;
|
|
20
|
+
selectOptions: typeof selectOptions;
|
|
21
|
+
type: typeof type;
|
|
22
|
+
upload: typeof upload;
|
|
23
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
5
|
-
export
|
|
1
|
+
import { type Options } from '../options';
|
|
2
|
+
import { type PointerInput } from '../pointer';
|
|
3
|
+
import { type System } from '../system';
|
|
4
|
+
import { type UserEventApi } from './setup';
|
|
5
|
+
export type DirectOptions = Options & {
|
|
6
6
|
keyboardState?: System;
|
|
7
7
|
pointerState?: System;
|
|
8
8
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { dispatchEvent, dispatchUIEvent } from '../event';
|
|
2
2
|
import { Options } from '../options';
|
|
3
3
|
import { System } from '../system';
|
|
4
|
-
import
|
|
4
|
+
import { userEventApi } from './api';
|
|
5
5
|
import { DirectOptions } from './directApi';
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type UserEventApi = typeof userEventApi;
|
|
7
|
+
export type UserEvent = {
|
|
8
8
|
readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
|
|
9
9
|
} & {
|
|
10
10
|
readonly [k in keyof UserEventApi]: (...args: Parameters<UserEventApi[k]>) => ReturnType<UserEventApi[k]>;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type Instance = UserEventApi & {
|
|
13
13
|
config: Config;
|
|
14
14
|
dispatchEvent: OmitThisParameter<typeof dispatchEvent>;
|
|
15
15
|
dispatchUIEvent: OmitThisParameter<typeof dispatchUIEvent>;
|
|
16
16
|
system: System;
|
|
17
17
|
levelRefs: Record<number, object | undefined>;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type Config = Required<Options>;
|
|
20
20
|
export declare function createConfig(options?: Options, defaults?: Required<Options>, node?: Node): Config;
|
|
21
21
|
/**
|
|
22
22
|
* Start a "session" with userEvent.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type pointerKey } from './shared';
|
|
2
2
|
export declare class Buttons {
|
|
3
3
|
private readonly pressed;
|
|
4
4
|
getButtons(): number;
|
|
@@ -14,7 +14,7 @@ export declare const MouseButton: {
|
|
|
14
14
|
readonly forward: 4;
|
|
15
15
|
readonly X2: 4;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type MouseButton = keyof typeof MouseButton | number;
|
|
18
18
|
export declare function getMouseButtonId(button?: MouseButton): number;
|
|
19
19
|
export declare const MouseButtonFlip: {
|
|
20
20
|
readonly 1: 2;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
|
+
import { type Pointer } from './pointer';
|
|
3
3
|
import { pointerKey, PointerPosition } from './shared';
|
|
4
4
|
/**
|
|
5
5
|
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
2
|
import { pointerKey, PointerPosition } from './shared';
|
|
3
|
-
|
|
3
|
+
type PointerInit = {
|
|
4
4
|
pointerId: number;
|
|
5
5
|
pointerType: string;
|
|
6
6
|
isPrimary: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
export declare function clear(this: Instance, element: Element): Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
export declare function selectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
3
3
|
export declare function deselectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
|
+
import { type Options } from '../options';
|
|
3
3
|
export interface typeOptions {
|
|
4
4
|
skipClick?: Options['skipClick'];
|
|
5
5
|
skipAutoClose?: Options['skipAutoClose'];
|
|
@@ -8,7 +8,7 @@ declare enum clickableInputTypes {
|
|
|
8
8
|
'checkbox' = "checkbox",
|
|
9
9
|
'radio' = "radio"
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type ClickableInputOrButton = HTMLButtonElement | (HTMLInputElement & {
|
|
12
12
|
type: clickableInputTypes;
|
|
13
13
|
});
|
|
14
14
|
export declare function isClickableInput(element: Element): element is ClickableInputOrButton;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function createClipboardItem(window: Window & typeof globalThis, ...blobs: Array<Blob | string>): ClipboardItem;
|
|
2
|
-
|
|
2
|
+
type ClipboardStubControlInstance = {
|
|
3
3
|
resetClipboardStub: () => void;
|
|
4
4
|
detachClipboardStub: () => void;
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isContentEditable } from './isContentEditable';
|
|
2
|
-
|
|
2
|
+
type GuardedType<T> = T extends (x: any) => x is infer R ? R : never;
|
|
3
3
|
export declare function isEditable(element: Element): element is GuardedType<typeof isContentEditable> | (EditableInputOrTextarea & {
|
|
4
4
|
readOnly: false;
|
|
5
5
|
});
|
|
@@ -17,7 +17,7 @@ declare enum editableInputTypes {
|
|
|
17
17
|
'url' = "url",
|
|
18
18
|
'week' = "week"
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export type EditableInputOrTextarea = HTMLTextAreaElement | (HTMLInputElement & {
|
|
21
21
|
type: editableInputTypes;
|
|
22
22
|
});
|
|
23
23
|
export declare function isEditableInputOrTextArea(element: Element): element is EditableInputOrTextarea;
|
|
@@ -6,7 +6,7 @@ declare enum maxLengthSupportedTypes {
|
|
|
6
6
|
'text' = "text",
|
|
7
7
|
'url' = "url"
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
type ElementWithMaxLengthSupport = HTMLTextAreaElement | (HTMLInputElement & {
|
|
10
10
|
type: maxLengthSupportedTypes;
|
|
11
11
|
});
|
|
12
12
|
export declare function getMaxLength(element: ElementWithMaxLengthSupport): number | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type tag = keyof HTMLElementTagNameMap;
|
|
2
2
|
export declare function isElementType<T extends tag, P extends {
|
|
3
3
|
[k: string]: unknown;
|
|
4
4
|
} | undefined = undefined>(element: Element, tag: T | T[], props?: P): element is P extends undefined ? HTMLElementTagNameMap[T] : HTMLElementTagNameMap[T] & P;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
2
|
export declare enum ApiLevel {
|
|
3
3
|
Trigger = 2,
|
|
4
4
|
Call = 1
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export type LevelRefs = Record<ApiLevel, object | undefined>;
|
|
7
7
|
export declare function setLevelRef(instance: Instance, level: ApiLevel): void;
|
|
8
8
|
export declare function getLevelRef(instance: Instance, level: ApiLevel): object | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
2
|
export declare function wait(config: Instance['config']): Promise<[void, void]> | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
2
|
import { ApiLevel } from '../misc/level';
|
|
3
3
|
export declare function hasPointerEvents(instance: Instance, element: Element): boolean;
|
|
4
4
|
declare function closestPointerEventsDeclaration(element: Element): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/user-event",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.1",
|
|
4
4
|
"description": "Fire events the same way the user does",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-testing-library",
|
|
@@ -29,36 +29,47 @@
|
|
|
29
29
|
"build": "scripts ts-build2 --cjs --target es2019",
|
|
30
30
|
"lint": "kcd-scripts lint",
|
|
31
31
|
"setup": "npm install && npm run validate -s",
|
|
32
|
+
"setup:env": "node --experimental-import-meta-resolve scripts/setup.js",
|
|
32
33
|
"test": "kcd-scripts test",
|
|
34
|
+
"test:jest": "kcd-scripts test",
|
|
35
|
+
"test:toolbox": "NODE_OPTIONS='--experimental-vm-modules --experimental-modules --experimental-import-meta-resolve' node scripts/test.js",
|
|
33
36
|
"test:debug": "kcd-scripts --inspect-brk test --runInBand",
|
|
34
37
|
"test:update": "npm test -- --updateSnapshot --coverage",
|
|
35
38
|
"validate": "kcd-scripts typecheck"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
38
41
|
"@ph.fritsche/scripts-config": "^2.4.0",
|
|
39
|
-
"@
|
|
42
|
+
"@ph.fritsche/toolbox": "^1.0.0-alpha.1",
|
|
43
|
+
"@testing-library/dom": "^8.19.0",
|
|
40
44
|
"@testing-library/jest-dom": "^5.16.3",
|
|
41
|
-
"@testing-library/react": "^13.
|
|
45
|
+
"@testing-library/react": "^13.4.0",
|
|
42
46
|
"@types/jest-in-case": "^1.0.3",
|
|
43
|
-
"@types/react": "^
|
|
44
|
-
"
|
|
45
|
-
"
|
|
47
|
+
"@types/react": "^18.0.25",
|
|
48
|
+
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
49
|
+
"css.escape": "^1.5.1",
|
|
50
|
+
"eslint-import-resolver-typescript": "^3.5.2",
|
|
51
|
+
"eslint-plugin-local-rules": "^1.3.2",
|
|
52
|
+
"expect": "^28.1.3",
|
|
46
53
|
"is-ci": "^3.0.1",
|
|
54
|
+
"istanbul-lib-coverage": "^3.2.0",
|
|
55
|
+
"istanbul-lib-report": "^3.0.0",
|
|
56
|
+
"istanbul-lib-source-maps": "^4.0.1",
|
|
57
|
+
"istanbul-reports": "^3.1.5",
|
|
47
58
|
"jest-in-case": "^1.0.2",
|
|
59
|
+
"jest-mock": "^28.1.3",
|
|
48
60
|
"jest-serializer-ansi": "^1.0.3",
|
|
61
|
+
"jsdom": "^20.0.3",
|
|
49
62
|
"kcd-scripts": "^12.1.0",
|
|
50
63
|
"react": "^18.0.0",
|
|
51
64
|
"react-dom": "^18.0.0",
|
|
52
|
-
"react17": "npm:react@^17.0.2",
|
|
53
|
-
"reactDom17": "npm:react-dom@^17.0.2",
|
|
54
|
-
"reactIs17": "npm:react-is@^17.0.2",
|
|
55
|
-
"reactTesting17": "npm:@testing-library/react@^12.1.3",
|
|
56
65
|
"shared-scripts": "^1.5.1",
|
|
57
|
-
"
|
|
66
|
+
"ts-node": "^10.9.1",
|
|
67
|
+
"typescript": "^4.9.3"
|
|
58
68
|
},
|
|
59
69
|
"peerDependencies": {
|
|
60
70
|
"@testing-library/dom": ">=7.21.4"
|
|
61
71
|
},
|
|
72
|
+
"dependencies": {},
|
|
62
73
|
"main": "./dist/cjs/index.js",
|
|
63
74
|
"module": "./dist/esm/index.js",
|
|
64
75
|
"types": "./dist/types/index.d.ts",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|