@testing-library/user-event 14.0.0-alpha.8 → 14.0.0-beta.11
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/README.md +5 -192
- package/dist/index.cjs +2864 -0
- package/dist/index.mjs +2935 -0
- package/dist/types/clipboard/copy.d.ts +2 -0
- package/dist/types/clipboard/cut.d.ts +2 -0
- package/dist/types/clipboard/index.d.ts +3 -0
- package/dist/types/clipboard/paste.d.ts +2 -0
- package/dist/types/convenience/click.d.ts +4 -0
- package/dist/types/convenience/hover.d.ts +3 -0
- package/dist/types/convenience/index.d.ts +3 -0
- package/dist/types/convenience/tab.d.ts +4 -0
- package/dist/{document → types/document}/index.d.ts +0 -0
- package/dist/{document → types/document}/interceptor.d.ts +0 -0
- package/dist/{document → types/document}/selection.d.ts +0 -0
- package/dist/{document → types/document}/value.d.ts +0 -0
- package/dist/types/event/behavior/click.d.ts +1 -0
- package/dist/types/event/behavior/index.d.ts +6 -0
- package/dist/types/event/behavior/keydown.d.ts +1 -0
- package/dist/types/event/behavior/keypress.d.ts +1 -0
- package/dist/types/event/behavior/keyup.d.ts +1 -0
- package/dist/types/event/behavior/registry.d.ts +9 -0
- package/dist/types/event/createEvent.d.ts +8 -0
- package/dist/types/event/dispatchEvent.d.ts +2 -0
- package/dist/types/event/eventMap.d.ts +342 -0
- package/dist/types/event/eventTypes.d.ts +2 -0
- package/dist/types/event/index.d.ts +6 -0
- package/dist/types/event/types.d.ts +13 -0
- package/dist/types/event/wrapEvent.d.ts +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/keyboard/index.d.ts +7 -0
- package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
- package/dist/types/keyboard/keyboardAction.d.ts +10 -0
- package/dist/types/keyboard/modifiers.d.ts +9 -0
- package/dist/{keyboard/getNextKeyDef.d.ts → types/keyboard/parseKeyDef.d.ts} +4 -6
- package/dist/{keyboard → types/keyboard}/types.d.ts +19 -26
- package/dist/types/options.d.ts +117 -0
- package/dist/types/pointer/firePointerEvents.d.ts +11 -0
- package/dist/types/pointer/index.d.ts +10 -0
- package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
- package/dist/types/pointer/parseKeyDef.d.ts +6 -0
- package/dist/{pointer → types/pointer}/pointerAction.d.ts +3 -2
- package/dist/types/pointer/pointerMove.d.ts +6 -0
- package/dist/types/pointer/pointerPress.d.ts +8 -0
- package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
- package/dist/{pointer → types/pointer}/types.d.ts +2 -12
- package/dist/types/setup/api.d.ts +5 -0
- package/dist/types/setup/config.d.ts +10 -0
- package/dist/types/setup/directApi.d.ts +19 -0
- package/dist/types/setup/index.d.ts +36 -0
- package/dist/types/setup/setup.d.ts +20 -0
- package/dist/types/setup/wrapAsync.d.ts +4 -0
- package/dist/types/utility/clear.d.ts +2 -0
- package/dist/types/utility/index.d.ts +4 -0
- package/dist/types/utility/selectOptions.d.ts +3 -0
- package/dist/types/utility/type.d.ts +9 -0
- package/dist/types/utility/upload.d.ts +5 -0
- package/dist/{utils → types/utils}/click/isClickableInput.d.ts +0 -0
- package/dist/types/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +9 -0
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +2 -0
- package/dist/types/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/getValue.d.ts +0 -0
- package/dist/types/utils/edit/input.d.ts +2 -0
- package/dist/{utils → types/utils}/edit/isContentEditable.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isEditable.d.ts +0 -0
- package/dist/types/utils/edit/isValidDateOrTimeValue.d.ts +3 -0
- package/dist/{utils → types/utils}/edit/maxLength.d.ts +0 -0
- package/dist/types/utils/edit/setFiles.d.ts +12 -0
- package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
- package/dist/types/utils/focus/copySelection.d.ts +1 -0
- package/dist/types/utils/focus/cursor.d.ts +9 -0
- package/dist/{utils → types/utils}/focus/focus.d.ts +3 -0
- package/dist/{utils → types/utils}/focus/getActiveElement.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/getTabDestination.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/isFocusable.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selectAll.d.ts +1 -0
- package/dist/{utils → types/utils}/focus/selection.d.ts +4 -0
- package/dist/{utils → types/utils}/focus/selector.d.ts +0 -0
- package/dist/{utils → types/utils}/index.d.ts +14 -11
- package/dist/{utils → types/utils}/keyDef/readNextDescriptor.d.ts +0 -0
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +5 -0
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
- package/dist/types/utils/misc/cloneEvent.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/eventWrapper.d.ts +0 -0
- package/dist/types/utils/misc/findClosest.d.ts +1 -0
- package/dist/types/utils/misc/getDocumentFromNode.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/isDescendantOrSelf.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isDisabled.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isElementType.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isVisible.d.ts +0 -0
- package/dist/types/utils/misc/level.d.ts +17 -0
- package/dist/{utils → types/utils}/misc/wait.d.ts +0 -0
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -0
- package/dist/{utils → types/utils}/pointer/mouseButtons.d.ts +0 -0
- package/package.json +13 -30
- package/CHANGELOG.md +0 -5
- package/dist/clear.d.ts +0 -2
- package/dist/clear.js +0 -46
- package/dist/click.d.ts +0 -9
- package/dist/click.js +0 -62
- package/dist/document/index.js +0 -100
- package/dist/document/interceptor.js +0 -37
- package/dist/document/selection.js +0 -90
- package/dist/document/value.js +0 -77
- package/dist/hover.d.ts +0 -4
- package/dist/hover.js +0 -43
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -22
- package/dist/keyboard/getEventProps.d.ts +0 -17
- package/dist/keyboard/getEventProps.js +0 -33
- package/dist/keyboard/getNextKeyDef.js +0 -85
- package/dist/keyboard/index.d.ts +0 -19
- package/dist/keyboard/index.js +0 -78
- package/dist/keyboard/keyMap.js +0 -143
- package/dist/keyboard/keyboardImplementation.d.ts +0 -3
- package/dist/keyboard/keyboardImplementation.js +0 -169
- package/dist/keyboard/plugins/arrow.d.ts +0 -6
- package/dist/keyboard/plugins/arrow.js +0 -28
- package/dist/keyboard/plugins/character.d.ts +0 -5
- package/dist/keyboard/plugins/character.js +0 -166
- package/dist/keyboard/plugins/combination.d.ts +0 -5
- package/dist/keyboard/plugins/combination.js +0 -17
- package/dist/keyboard/plugins/control.d.ts +0 -6
- package/dist/keyboard/plugins/control.js +0 -52
- package/dist/keyboard/plugins/functional.d.ts +0 -11
- package/dist/keyboard/plugins/functional.js +0 -140
- package/dist/keyboard/plugins/index.d.ts +0 -8
- package/dist/keyboard/plugins/index.js +0 -42
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -3
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
- package/dist/keyboard/shared/index.d.ts +0 -1
- package/dist/keyboard/shared/index.js +0 -18
- package/dist/keyboard/specialCharMap.d.ts +0 -22
- package/dist/keyboard/specialCharMap.js +0 -30
- package/dist/keyboard/types.js +0 -19
- package/dist/paste.d.ts +0 -7
- package/dist/paste.js +0 -60
- package/dist/pointer/index.d.ts +0 -18
- package/dist/pointer/index.js +0 -90
- package/dist/pointer/keyMap.js +0 -29
- package/dist/pointer/parseKeyDef.d.ts +0 -6
- package/dist/pointer/parseKeyDef.js +0 -36
- package/dist/pointer/pointerAction.js +0 -52
- package/dist/pointer/pointerMove.d.ts +0 -5
- package/dist/pointer/pointerMove.js +0 -136
- package/dist/pointer/pointerPress.d.ts +0 -7
- package/dist/pointer/pointerPress.js +0 -330
- package/dist/pointer/resolveSelectionTarget.js +0 -75
- package/dist/pointer/types.js +0 -1
- package/dist/selectOptions.d.ts +0 -4
- package/dist/selectOptions.js +0 -142
- 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/upload.js +0 -92
- package/dist/utils/click/isClickableInput.js +0 -14
- package/dist/utils/edit/buildTimeValue.js +0 -44
- package/dist/utils/edit/calculateNewValue.d.ts +0 -16
- package/dist/utils/edit/calculateNewValue.js +0 -50
- package/dist/utils/edit/fireInputEvent.d.ts +0 -11
- package/dist/utils/edit/fireInputEvent.js +0 -65
- package/dist/utils/edit/getValue.js +0 -23
- package/dist/utils/edit/isContentEditable.js +0 -25
- package/dist/utils/edit/isEditable.js +0 -42
- package/dist/utils/edit/isValidDateValue.d.ts +0 -3
- package/dist/utils/edit/isValidDateValue.js +0 -12
- package/dist/utils/edit/isValidInputTimeValue.d.ts +0 -3
- package/dist/utils/edit/isValidInputTimeValue.js +0 -12
- package/dist/utils/edit/maxLength.js +0 -50
- package/dist/utils/edit/prepareInput.d.ts +0 -4
- package/dist/utils/edit/prepareInput.js +0 -60
- package/dist/utils/focus/blur.js +0 -19
- package/dist/utils/focus/focus.js +0 -22
- package/dist/utils/focus/getActiveElement.js +0 -26
- package/dist/utils/focus/getTabDestination.js +0 -71
- package/dist/utils/focus/isFocusable.js +0 -12
- package/dist/utils/focus/selectAll.js +0 -38
- package/dist/utils/focus/selection.js +0 -190
- package/dist/utils/focus/selector.js +0 -8
- package/dist/utils/index.js +0 -421
- package/dist/utils/keyDef/readNextDescriptor.js +0 -102
- package/dist/utils/misc/eventWrapper.js +0 -16
- package/dist/utils/misc/findClosest.d.ts +0 -1
- package/dist/utils/misc/findClosest.js +0 -20
- package/dist/utils/misc/hasFormSubmit.d.ts +0 -1
- package/dist/utils/misc/hasFormSubmit.js +0 -10
- package/dist/utils/misc/hasPointerEvents.d.ts +0 -15
- package/dist/utils/misc/hasPointerEvents.js +0 -24
- package/dist/utils/misc/isDescendantOrSelf.js +0 -20
- package/dist/utils/misc/isDisabled.js +0 -12
- package/dist/utils/misc/isElementType.js +0 -24
- package/dist/utils/misc/isVisible.js +0 -24
- package/dist/utils/misc/wait.js +0 -10
- package/dist/utils/pointer/fakeEvent.d.ts +0 -20
- package/dist/utils/pointer/fakeEvent.js +0 -91
- package/dist/utils/pointer/firePointerEvents.d.ts +0 -14
- package/dist/utils/pointer/firePointerEvents.js +0 -55
- package/dist/utils/pointer/mouseButtons.js +0 -45
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.resolveSelectionTarget = resolveSelectionTarget;
|
|
7
|
-
|
|
8
|
-
var _document = require("../document");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
|
|
12
|
-
function resolveSelectionTarget({
|
|
13
|
-
target,
|
|
14
|
-
node,
|
|
15
|
-
offset
|
|
16
|
-
}) {
|
|
17
|
-
if ((0, _utils.isElementType)(target, ['input', 'textarea'])) {
|
|
18
|
-
return {
|
|
19
|
-
node: target,
|
|
20
|
-
offset: offset != null ? offset : (0, _document.getUIValue)(target).length
|
|
21
|
-
};
|
|
22
|
-
} else if (node) {
|
|
23
|
-
return {
|
|
24
|
-
node,
|
|
25
|
-
offset: offset != null ? offset : node.nodeType === 3 ? node.nodeValue.length : node.childNodes.length
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return findNodeAtTextOffset(target, offset);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function findNodeAtTextOffset(node, offset, isRoot = true) {
|
|
33
|
-
// When clicking after the content the browser behavior can be complicated:
|
|
34
|
-
// 1. If there is textContent after the last element child,
|
|
35
|
-
// the cursor is moved there.
|
|
36
|
-
// 2. If there is textContent in the last element child,
|
|
37
|
-
// the browser moves the cursor to the last non-empty text node inside this element.
|
|
38
|
-
// 3. Otherwise the cursor is moved to the end of the target.
|
|
39
|
-
let i = offset === undefined ? node.childNodes.length - 1 : 0;
|
|
40
|
-
const step = offset === undefined ? -1 : +1;
|
|
41
|
-
|
|
42
|
-
while (offset === undefined ? i >= (isRoot ? Math.max(node.childNodes.length - 1, 0) : 0) : i <= node.childNodes.length) {
|
|
43
|
-
const c = node.childNodes.item(i);
|
|
44
|
-
const text = String(c.textContent);
|
|
45
|
-
|
|
46
|
-
if (text.length) {
|
|
47
|
-
if (offset !== undefined && text.length < offset) {
|
|
48
|
-
offset -= text.length;
|
|
49
|
-
} else if (c.nodeType === 1) {
|
|
50
|
-
return findNodeAtTextOffset(c, offset, false);
|
|
51
|
-
} else {
|
|
52
|
-
// The pre-commit hooks keeps changing this
|
|
53
|
-
// See https://github.com/kentcdodds/kcd-scripts/issues/218
|
|
54
|
-
|
|
55
|
-
/* istanbul ignore else */
|
|
56
|
-
// eslint-disable-next-line no-lonely-if
|
|
57
|
-
if (c.nodeType === 3) {
|
|
58
|
-
var _offset;
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
node: c,
|
|
62
|
-
offset: (_offset = offset) != null ? _offset : c.nodeValue.length
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
i += step;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
node,
|
|
73
|
-
offset: node.childNodes.length
|
|
74
|
-
};
|
|
75
|
-
}
|
package/dist/pointer/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/selectOptions.d.ts
DELETED
|
@@ -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, init?: MouseEventInit, options?: PointerOptions): void;
|
|
4
|
-
export declare function deselectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string, init?: MouseEventInit, options?: PointerOptions): void;
|
package/dist/selectOptions.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.deselectOptions = deselectOptions;
|
|
7
|
-
exports.selectOptions = selectOptions;
|
|
8
|
-
|
|
9
|
-
var _dom = require("@testing-library/dom");
|
|
10
|
-
|
|
11
|
-
var _utils = require("./utils");
|
|
12
|
-
|
|
13
|
-
function selectOptions(select, values, init, options = {}) {
|
|
14
|
-
return selectOptionsBase.call(this, true, select, values, init, options);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function deselectOptions(select, values, init, options = {}) {
|
|
18
|
-
return selectOptionsBase.call(this, false, select, values, init, options);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function selectOptionsBase(newValue, select, values, init, {
|
|
22
|
-
skipPointerEventsCheck
|
|
23
|
-
}) {
|
|
24
|
-
if (!newValue && !select.multiple) {
|
|
25
|
-
throw (0, _dom.getConfig)().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const valArray = Array.isArray(values) ? values : [values];
|
|
29
|
-
const allOptions = Array.from(select.querySelectorAll('option, [role="option"]'));
|
|
30
|
-
const selectedOptions = valArray.map(val => {
|
|
31
|
-
if (typeof val !== 'string' && allOptions.includes(val)) {
|
|
32
|
-
return val;
|
|
33
|
-
} else {
|
|
34
|
-
const matchingOption = allOptions.find(o => o.value === val || o.innerHTML === val);
|
|
35
|
-
|
|
36
|
-
if (matchingOption) {
|
|
37
|
-
return matchingOption;
|
|
38
|
-
} else {
|
|
39
|
-
throw (0, _dom.getConfig)().getElementError(`Value "${String(val)}" not found in options`, select);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}).filter(option => !(0, _utils.isDisabled)(option));
|
|
43
|
-
if ((0, _utils.isDisabled)(select) || !selectedOptions.length) return;
|
|
44
|
-
|
|
45
|
-
if ((0, _utils.isElementType)(select, 'select')) {
|
|
46
|
-
if (select.multiple) {
|
|
47
|
-
for (const option of selectedOptions) {
|
|
48
|
-
const withPointerEvents = skipPointerEventsCheck ? true : (0, _utils.hasPointerEvents)(option); // events fired for multiple select are weird. Can't use hover...
|
|
49
|
-
|
|
50
|
-
if (withPointerEvents) {
|
|
51
|
-
_dom.fireEvent.pointerOver(option, init);
|
|
52
|
-
|
|
53
|
-
_dom.fireEvent.pointerEnter(select, init);
|
|
54
|
-
|
|
55
|
-
_dom.fireEvent.mouseOver(option);
|
|
56
|
-
|
|
57
|
-
_dom.fireEvent.mouseEnter(select);
|
|
58
|
-
|
|
59
|
-
_dom.fireEvent.pointerMove(option, init);
|
|
60
|
-
|
|
61
|
-
_dom.fireEvent.mouseMove(option, init);
|
|
62
|
-
|
|
63
|
-
_dom.fireEvent.pointerDown(option, init);
|
|
64
|
-
|
|
65
|
-
_dom.fireEvent.mouseDown(option, init);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
(0, _utils.focus)(select);
|
|
69
|
-
|
|
70
|
-
if (withPointerEvents) {
|
|
71
|
-
_dom.fireEvent.pointerUp(option, init);
|
|
72
|
-
|
|
73
|
-
_dom.fireEvent.mouseUp(option, init);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
selectOption(option);
|
|
77
|
-
|
|
78
|
-
if (withPointerEvents) {
|
|
79
|
-
_dom.fireEvent.click(option, init);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
} else if (selectedOptions.length === 1) {
|
|
83
|
-
const withPointerEvents = skipPointerEventsCheck ? true : (0, _utils.hasPointerEvents)(select); // the click to open the select options
|
|
84
|
-
|
|
85
|
-
if (withPointerEvents) {
|
|
86
|
-
this.click(select, init, {
|
|
87
|
-
skipPointerEventsCheck: true
|
|
88
|
-
});
|
|
89
|
-
} else {
|
|
90
|
-
(0, _utils.focus)(select);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
selectOption(selectedOptions[0]);
|
|
94
|
-
|
|
95
|
-
if (withPointerEvents) {
|
|
96
|
-
// the browser triggers another click event on the select for the click on the option
|
|
97
|
-
// this second click has no 'down' phase
|
|
98
|
-
_dom.fireEvent.pointerOver(select, init);
|
|
99
|
-
|
|
100
|
-
_dom.fireEvent.pointerEnter(select, init);
|
|
101
|
-
|
|
102
|
-
_dom.fireEvent.mouseOver(select);
|
|
103
|
-
|
|
104
|
-
_dom.fireEvent.mouseEnter(select);
|
|
105
|
-
|
|
106
|
-
_dom.fireEvent.pointerUp(select, init);
|
|
107
|
-
|
|
108
|
-
_dom.fireEvent.mouseUp(select, init);
|
|
109
|
-
|
|
110
|
-
_dom.fireEvent.click(select, init);
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
throw (0, _dom.getConfig)().getElementError(`Cannot select multiple options on a non-multiple select`, select);
|
|
114
|
-
}
|
|
115
|
-
} else if (select.getAttribute('role') === 'listbox') {
|
|
116
|
-
selectedOptions.forEach(option => {
|
|
117
|
-
this.hover(option, init, {
|
|
118
|
-
skipPointerEventsCheck
|
|
119
|
-
});
|
|
120
|
-
this.click(option, init, {
|
|
121
|
-
skipPointerEventsCheck
|
|
122
|
-
});
|
|
123
|
-
this.unhover(option, init, {
|
|
124
|
-
skipPointerEventsCheck
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
} else {
|
|
128
|
-
throw (0, _dom.getConfig)().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function selectOption(option) {
|
|
132
|
-
option.selected = newValue;
|
|
133
|
-
(0, _dom.fireEvent)(select, (0, _dom.createEvent)('input', select, {
|
|
134
|
-
bubbles: true,
|
|
135
|
-
cancelable: false,
|
|
136
|
-
composed: true,
|
|
137
|
-
...init
|
|
138
|
-
}));
|
|
139
|
-
|
|
140
|
-
_dom.fireEvent.change(select, init);
|
|
141
|
-
}
|
|
142
|
-
}
|
package/dist/setup.d.ts
DELETED
|
@@ -1,92 +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 { paste } from './paste';
|
|
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
|
-
dblClick: typeof dblClick;
|
|
18
|
-
deselectOptions: typeof deselectOptions;
|
|
19
|
-
hover: typeof hover;
|
|
20
|
-
keyboard: typeof keyboard;
|
|
21
|
-
paste: typeof paste;
|
|
22
|
-
pointer: typeof pointer;
|
|
23
|
-
selectOptions: typeof selectOptions;
|
|
24
|
-
tab: typeof tab;
|
|
25
|
-
tripleClick: typeof tripleClick;
|
|
26
|
-
type: typeof type;
|
|
27
|
-
unhover: typeof unhover;
|
|
28
|
-
upload: typeof upload;
|
|
29
|
-
};
|
|
30
|
-
export declare type UserEventApis = typeof userEventApis;
|
|
31
|
-
declare type setup = ReturnType<typeof _setup>['setup'];
|
|
32
|
-
export declare type UserEvent = UserEventApis & {
|
|
33
|
-
setup: setup;
|
|
34
|
-
};
|
|
35
|
-
declare type ClickOptions = Omit<clickOptions, 'clickCount'>;
|
|
36
|
-
declare type KeyboardOptions = Partial<keyboardOptions>;
|
|
37
|
-
declare type PointerApiOptions = Partial<pointerOptions>;
|
|
38
|
-
declare type TabOptions = Omit<tabOptions, 'shift'>;
|
|
39
|
-
declare type TypeOptions = Omit<typeOptions, 'initialSelectionStart' | 'initialSelectionEnd'>;
|
|
40
|
-
declare type UploadOptions = uploadOptions;
|
|
41
|
-
interface SetupOptions extends ClickOptions, KeyboardOptions, PointerOptions, PointerApiOptions, TabOptions, TypeOptions, UploadOptions {
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Start a "session" with userEvent.
|
|
45
|
-
* All APIs returned by this function share an input device state and a default configuration.
|
|
46
|
-
*/
|
|
47
|
-
export declare function setup(options?: SetupOptions): {
|
|
48
|
-
clear: typeof clear;
|
|
49
|
-
click: typeof click;
|
|
50
|
-
dblClick: typeof dblClick;
|
|
51
|
-
deselectOptions: typeof deselectOptions;
|
|
52
|
-
hover: typeof hover;
|
|
53
|
-
keyboard: typeof keyboard;
|
|
54
|
-
paste: typeof paste;
|
|
55
|
-
pointer: typeof pointer;
|
|
56
|
-
selectOptions: typeof selectOptions;
|
|
57
|
-
tab: typeof tab;
|
|
58
|
-
tripleClick: typeof tripleClick;
|
|
59
|
-
type: typeof type;
|
|
60
|
-
unhover: typeof unhover;
|
|
61
|
-
upload: typeof upload;
|
|
62
|
-
} & {
|
|
63
|
-
/**
|
|
64
|
-
* Create a set of callbacks with different default settings but the same state.
|
|
65
|
-
*/
|
|
66
|
-
setup(options: SetupOptions): {
|
|
67
|
-
clear: typeof clear;
|
|
68
|
-
click: typeof click;
|
|
69
|
-
dblClick: typeof dblClick;
|
|
70
|
-
deselectOptions: typeof deselectOptions;
|
|
71
|
-
hover: typeof hover;
|
|
72
|
-
keyboard: typeof keyboard;
|
|
73
|
-
paste: typeof paste;
|
|
74
|
-
pointer: typeof pointer;
|
|
75
|
-
selectOptions: typeof selectOptions;
|
|
76
|
-
tab: typeof tab;
|
|
77
|
-
tripleClick: typeof tripleClick;
|
|
78
|
-
type: typeof type;
|
|
79
|
-
unhover: typeof unhover;
|
|
80
|
-
upload: typeof upload;
|
|
81
|
-
} & any;
|
|
82
|
-
};
|
|
83
|
-
declare function _setup({ applyAccept, autoModify, delay, document, keyboardMap, pointerMap, skipAutoClose, skipClick, skipHover, skipPointerEventsCheck, }: SetupOptions, { keyboardState, pointerState, }: {
|
|
84
|
-
keyboardState: keyboardState;
|
|
85
|
-
pointerState: pointerState;
|
|
86
|
-
}): UserEventApis & {
|
|
87
|
-
/**
|
|
88
|
-
* Create a set of callbacks with different default settings but the same state.
|
|
89
|
-
*/
|
|
90
|
-
setup(options: SetupOptions): ReturnType<typeof _setup>;
|
|
91
|
-
};
|
|
92
|
-
export {};
|
package/dist/setup.js
DELETED
|
@@ -1,203 +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 _paste = require("./paste");
|
|
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
|
-
const userEventApis = {
|
|
32
|
-
clear: _clear.clear,
|
|
33
|
-
click: _click.click,
|
|
34
|
-
dblClick: _click.dblClick,
|
|
35
|
-
deselectOptions: _selectOptions.deselectOptions,
|
|
36
|
-
hover: _hover.hover,
|
|
37
|
-
keyboard: _keyboard.keyboard,
|
|
38
|
-
paste: _paste.paste,
|
|
39
|
-
pointer: _pointer.pointer,
|
|
40
|
-
selectOptions: _selectOptions.selectOptions,
|
|
41
|
-
tab: _tab.tab,
|
|
42
|
-
tripleClick: _click.tripleClick,
|
|
43
|
-
type: _type.type,
|
|
44
|
-
unhover: _hover.unhover,
|
|
45
|
-
upload: _upload.upload
|
|
46
|
-
};
|
|
47
|
-
exports.userEventApis = userEventApis;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Start a "session" with userEvent.
|
|
51
|
-
* All APIs returned by this function share an input device state and a default configuration.
|
|
52
|
-
*/
|
|
53
|
-
function setup(options = {}) {
|
|
54
|
-
var _options$document;
|
|
55
|
-
|
|
56
|
-
(0, _document.prepareDocument)((_options$document = options.document) != null ? _options$document : document);
|
|
57
|
-
return _setup(options, {
|
|
58
|
-
keyboardState: (0, _keyboard.createKeyboardState)(),
|
|
59
|
-
pointerState: (0, _pointer.createPointerState)()
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _setup({
|
|
64
|
-
applyAccept,
|
|
65
|
-
autoModify,
|
|
66
|
-
delay = 0,
|
|
67
|
-
document,
|
|
68
|
-
keyboardMap,
|
|
69
|
-
pointerMap,
|
|
70
|
-
skipAutoClose,
|
|
71
|
-
skipClick,
|
|
72
|
-
skipHover,
|
|
73
|
-
skipPointerEventsCheck = false
|
|
74
|
-
}, {
|
|
75
|
-
keyboardState,
|
|
76
|
-
pointerState
|
|
77
|
-
}) {
|
|
78
|
-
const keyboardDefaults = {
|
|
79
|
-
autoModify,
|
|
80
|
-
delay,
|
|
81
|
-
document,
|
|
82
|
-
keyboardMap
|
|
83
|
-
};
|
|
84
|
-
const pointerDefaults = {
|
|
85
|
-
skipPointerEventsCheck
|
|
86
|
-
};
|
|
87
|
-
const pointerApiDefaults = {
|
|
88
|
-
delay,
|
|
89
|
-
pointerMap
|
|
90
|
-
};
|
|
91
|
-
const clickDefaults = {
|
|
92
|
-
skipHover
|
|
93
|
-
};
|
|
94
|
-
const typeDefaults = {
|
|
95
|
-
delay,
|
|
96
|
-
skipAutoClose,
|
|
97
|
-
skipClick
|
|
98
|
-
};
|
|
99
|
-
const uploadDefaults = {
|
|
100
|
-
applyAccept
|
|
101
|
-
};
|
|
102
|
-
const userEvent = {
|
|
103
|
-
clear: (...args) => {
|
|
104
|
-
return _clear.clear.call(userEvent, ...args);
|
|
105
|
-
},
|
|
106
|
-
click: (...args) => {
|
|
107
|
-
args[2] = { ...pointerDefaults,
|
|
108
|
-
...clickDefaults,
|
|
109
|
-
...args[2]
|
|
110
|
-
};
|
|
111
|
-
return _click.click.call(userEvent, ...args);
|
|
112
|
-
},
|
|
113
|
-
dblClick: (...args) => {
|
|
114
|
-
args[2] = { ...pointerDefaults,
|
|
115
|
-
...clickDefaults,
|
|
116
|
-
...args[2]
|
|
117
|
-
};
|
|
118
|
-
return _click.dblClick.call(userEvent, ...args);
|
|
119
|
-
},
|
|
120
|
-
deselectOptions: (...args) => {
|
|
121
|
-
args[3] = { ...pointerDefaults,
|
|
122
|
-
...args[3]
|
|
123
|
-
};
|
|
124
|
-
return _selectOptions.deselectOptions.call(userEvent, ...args);
|
|
125
|
-
},
|
|
126
|
-
hover: (...args) => {
|
|
127
|
-
args[2] = { ...pointerDefaults,
|
|
128
|
-
...args[2]
|
|
129
|
-
};
|
|
130
|
-
return _hover.hover.call(userEvent, ...args);
|
|
131
|
-
},
|
|
132
|
-
// keyboard needs typecasting because of the overloading
|
|
133
|
-
keyboard: (...args) => {
|
|
134
|
-
args[1] = { ...keyboardDefaults,
|
|
135
|
-
...args[1],
|
|
136
|
-
keyboardState
|
|
137
|
-
};
|
|
138
|
-
const ret = (0, _keyboard.keyboard)(...args);
|
|
139
|
-
|
|
140
|
-
if (ret instanceof Promise) {
|
|
141
|
-
return ret.then(() => undefined);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
paste: (...args) => {
|
|
145
|
-
return _paste.paste.call(userEvent, ...args);
|
|
146
|
-
},
|
|
147
|
-
// pointer needs typecasting because of the overloading
|
|
148
|
-
pointer: (...args) => {
|
|
149
|
-
args[1] = { ...pointerApiDefaults,
|
|
150
|
-
...args[1],
|
|
151
|
-
pointerState,
|
|
152
|
-
keyboardState
|
|
153
|
-
};
|
|
154
|
-
const ret = (0, _pointer.pointer)(...args);
|
|
155
|
-
|
|
156
|
-
if (ret instanceof Promise) {
|
|
157
|
-
return ret.then(() => undefined);
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
selectOptions: (...args) => {
|
|
161
|
-
args[3] = { ...pointerDefaults,
|
|
162
|
-
...args[3]
|
|
163
|
-
};
|
|
164
|
-
return _selectOptions.selectOptions.call(userEvent, ...args);
|
|
165
|
-
},
|
|
166
|
-
setup: options => {
|
|
167
|
-
return _setup({ ...keyboardDefaults,
|
|
168
|
-
...pointerDefaults,
|
|
169
|
-
...clickDefaults,
|
|
170
|
-
...options
|
|
171
|
-
}, {
|
|
172
|
-
keyboardState,
|
|
173
|
-
pointerState
|
|
174
|
-
});
|
|
175
|
-
},
|
|
176
|
-
tab: (...args) => {
|
|
177
|
-
return _tab.tab.call(userEvent, ...args);
|
|
178
|
-
},
|
|
179
|
-
tripleClick: (...args) => {
|
|
180
|
-
return _click.tripleClick.call(userEvent, ...args);
|
|
181
|
-
},
|
|
182
|
-
// type needs typecasting because of the overloading
|
|
183
|
-
type: (...args) => {
|
|
184
|
-
args[2] = { ...typeDefaults,
|
|
185
|
-
...args[2]
|
|
186
|
-
};
|
|
187
|
-
return _type.type.call(userEvent, ...args);
|
|
188
|
-
},
|
|
189
|
-
unhover: (...args) => {
|
|
190
|
-
args[2] = { ...pointerDefaults,
|
|
191
|
-
...args[2]
|
|
192
|
-
};
|
|
193
|
-
return _hover.unhover.call(userEvent, ...args);
|
|
194
|
-
},
|
|
195
|
-
upload: (...args) => {
|
|
196
|
-
args[3] = { ...uploadDefaults,
|
|
197
|
-
...args[3]
|
|
198
|
-
};
|
|
199
|
-
return _upload.upload.call(userEvent, ...args);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
return userEvent;
|
|
203
|
-
}
|
package/dist/tab.d.ts
DELETED
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 {};
|