@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/options.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultOptionsSetup = exports.defaultOptionsDirect = void 0;
|
|
7
|
+
|
|
8
|
+
var _keyMap = require("./keyboard/keyMap");
|
|
9
|
+
|
|
10
|
+
var _keyMap2 = require("./pointer/keyMap");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default options applied when API is called per `userEvent.anyApi()`
|
|
14
|
+
*/
|
|
15
|
+
const defaultOptionsDirect = {
|
|
16
|
+
applyAccept: true,
|
|
17
|
+
autoModify: true,
|
|
18
|
+
delay: 0,
|
|
19
|
+
document: global.document,
|
|
20
|
+
keyboardMap: _keyMap.defaultKeyMap,
|
|
21
|
+
pointerMap: _keyMap2.defaultKeyMap,
|
|
22
|
+
skipAutoClose: false,
|
|
23
|
+
skipClick: false,
|
|
24
|
+
skipHover: false,
|
|
25
|
+
skipPointerEventsCheck: false,
|
|
26
|
+
writeToClipboard: false
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Default options applied when API is called per `userEvent().anyApi()`
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
exports.defaultOptionsDirect = defaultOptionsDirect;
|
|
33
|
+
const defaultOptionsSetup = { ...defaultOptionsDirect,
|
|
34
|
+
writeToClipboard: true
|
|
35
|
+
};
|
|
36
|
+
exports.defaultOptionsSetup = defaultOptionsSetup;
|
package/dist/pointer/index.d.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
+
import { UserEvent } from '../setup';
|
|
1
2
|
import { PointerAction, PointerActionTarget } from './pointerAction';
|
|
2
|
-
import type {
|
|
3
|
-
export
|
|
4
|
-
delay: 0;
|
|
5
|
-
} & inputDeviceState>): pointerState;
|
|
6
|
-
export declare function pointer(input: PointerInput, options: Partial<pointerOptions & {
|
|
7
|
-
delay: number;
|
|
8
|
-
} & inputDeviceState>): Promise<pointerState>;
|
|
3
|
+
import type { pointerState, pointerKey } from './types';
|
|
4
|
+
export type { pointerState, pointerKey };
|
|
9
5
|
declare type PointerActionInput = string | ({
|
|
10
6
|
keys: string;
|
|
11
7
|
} & PointerActionTarget) | PointerAction;
|
|
12
|
-
declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
|
|
13
|
-
export declare function
|
|
14
|
-
|
|
15
|
-
pointerState: pointerState;
|
|
16
|
-
};
|
|
17
|
-
export declare function createPointerState(): pointerState;
|
|
18
|
-
export {};
|
|
8
|
+
export declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
|
|
9
|
+
export declare function pointer(this: UserEvent, input: PointerInput): Promise<void>;
|
|
10
|
+
export declare function createPointerState(document: Document): pointerState;
|
package/dist/pointer/index.js
CHANGED
|
@@ -5,74 +5,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createPointerState = createPointerState;
|
|
7
7
|
exports.pointer = pointer;
|
|
8
|
-
exports.pointerImplementationWrapper = pointerImplementationWrapper;
|
|
9
8
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _keyboard = require("../keyboard");
|
|
9
|
+
var _setup = require("../setup");
|
|
13
10
|
|
|
14
11
|
var _parseKeyDef = require("./parseKeyDef");
|
|
15
12
|
|
|
16
|
-
var _keyMap = require("./keyMap");
|
|
17
|
-
|
|
18
13
|
var _pointerAction = require("./pointerAction");
|
|
19
14
|
|
|
20
|
-
function pointer(input
|
|
21
|
-
var _options$delay;
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
promise,
|
|
25
|
-
pointerState
|
|
26
|
-
} = pointerImplementationWrapper(input, options);
|
|
27
|
-
|
|
28
|
-
if (((_options$delay = options.delay) != null ? _options$delay : 0) > 0) {
|
|
29
|
-
return (0, _dom.getConfig)().asyncWrapper(() => promise.then(() => pointerState));
|
|
30
|
-
} else {
|
|
31
|
-
// prevent users from dealing with UnhandledPromiseRejectionWarning in sync call
|
|
32
|
-
promise.catch(console.error);
|
|
33
|
-
return pointerState;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function pointerImplementationWrapper(input, config) {
|
|
15
|
+
async function pointer(input) {
|
|
38
16
|
const {
|
|
39
|
-
pointerState = createPointerState(),
|
|
40
|
-
keyboardState = (0, _keyboard.createKeyboardState)(),
|
|
41
|
-
delay = 0,
|
|
42
|
-
pointerMap = _keyMap.defaultKeyMap
|
|
43
|
-
} = config;
|
|
44
|
-
const options = {
|
|
45
|
-
delay,
|
|
46
17
|
pointerMap
|
|
47
|
-
};
|
|
18
|
+
} = this[_setup.Config];
|
|
48
19
|
const actions = [];
|
|
49
20
|
(Array.isArray(input) ? input : [input]).forEach(actionInput => {
|
|
50
21
|
if (typeof actionInput === 'string') {
|
|
51
|
-
actions.push(...(0, _parseKeyDef.parseKeyDef)(
|
|
22
|
+
actions.push(...(0, _parseKeyDef.parseKeyDef)(pointerMap, actionInput));
|
|
52
23
|
} else if ('keys' in actionInput) {
|
|
53
|
-
actions.push(...(0, _parseKeyDef.parseKeyDef)(actionInput.keys
|
|
24
|
+
actions.push(...(0, _parseKeyDef.parseKeyDef)(pointerMap, actionInput.keys).map(i => ({ ...actionInput,
|
|
54
25
|
...i
|
|
55
26
|
})));
|
|
56
27
|
} else {
|
|
57
28
|
actions.push(actionInput);
|
|
58
29
|
}
|
|
59
30
|
});
|
|
60
|
-
return
|
|
61
|
-
promise: (0, _pointerAction.pointerAction)(actions, options, {
|
|
62
|
-
pointerState,
|
|
63
|
-
keyboardState
|
|
64
|
-
}),
|
|
65
|
-
pointerState
|
|
66
|
-
};
|
|
31
|
+
return (0, _pointerAction.pointerAction)(this[_setup.Config], actions).then(() => undefined);
|
|
67
32
|
}
|
|
68
33
|
|
|
69
|
-
function createPointerState() {
|
|
34
|
+
function createPointerState(document) {
|
|
70
35
|
return {
|
|
71
36
|
pointerId: 1,
|
|
72
37
|
position: {
|
|
73
38
|
mouse: {
|
|
74
39
|
pointerType: 'mouse',
|
|
75
40
|
pointerId: 1,
|
|
41
|
+
target: document.body,
|
|
76
42
|
coords: {
|
|
77
43
|
clientX: 0,
|
|
78
44
|
clientY: 0,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { pointerKey
|
|
2
|
-
export declare function parseKeyDef(
|
|
1
|
+
import { pointerKey } from './types';
|
|
2
|
+
export declare function parseKeyDef(pointerMap: pointerKey[], keys: string): {
|
|
3
3
|
keyDef: pointerKey;
|
|
4
4
|
releasePrevious: boolean;
|
|
5
5
|
releaseSelf: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Config } from '../setup';
|
|
1
2
|
import { PointerMoveAction } from './pointerMove';
|
|
2
3
|
import { PointerPressAction } from './pointerPress';
|
|
3
|
-
import {
|
|
4
|
+
import { PointerTarget, SelectionTarget } from './types';
|
|
4
5
|
export declare type PointerActionTarget = Partial<PointerTarget> & Partial<SelectionTarget>;
|
|
5
6
|
export declare type PointerAction = PointerActionTarget & (Omit<PointerPressAction, 'target' | 'coords'> | Omit<PointerMoveAction, 'target' | 'coords'>);
|
|
6
|
-
export declare function pointerAction(actions: PointerAction[]
|
|
7
|
+
export declare function pointerAction(config: Config, actions: PointerAction[]): Promise<void>;
|
|
@@ -11,36 +11,30 @@ var _pointerMove = require("./pointerMove");
|
|
|
11
11
|
|
|
12
12
|
var _pointerPress = require("./pointerPress");
|
|
13
13
|
|
|
14
|
-
async function pointerAction(
|
|
15
|
-
const ret = [];
|
|
16
|
-
|
|
14
|
+
async function pointerAction(config, actions) {
|
|
17
15
|
for (let i = 0; i < actions.length; i++) {
|
|
18
16
|
var _action$target, _action$coords;
|
|
19
17
|
|
|
20
18
|
const action = actions[i];
|
|
21
19
|
const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? action.keyDef.pointerType === 'touch' ? action.keyDef.name : action.keyDef.pointerType : 'mouse';
|
|
22
|
-
const target = (_action$target = action.target) != null ? _action$target : getPrevTarget(pointerName,
|
|
23
|
-
const coords = (_action$coords = action.coords) != null ? _action$coords : pointerName in
|
|
24
|
-
|
|
20
|
+
const target = (_action$target = action.target) != null ? _action$target : getPrevTarget(pointerName, config.pointerState);
|
|
21
|
+
const coords = (_action$coords = action.coords) != null ? _action$coords : pointerName in config.pointerState.position ? config.pointerState.position[pointerName].coords : undefined;
|
|
22
|
+
await ('keyDef' in action ? (0, _pointerPress.pointerPress)({ ...action,
|
|
25
23
|
target,
|
|
26
24
|
coords
|
|
27
|
-
},
|
|
25
|
+
}, config) : (0, _pointerMove.pointerMove)({ ...action,
|
|
28
26
|
target,
|
|
29
27
|
coords
|
|
30
|
-
},
|
|
31
|
-
ret.push(promise);
|
|
32
|
-
|
|
33
|
-
if (options.delay > 0) {
|
|
34
|
-
await promise;
|
|
28
|
+
}, config));
|
|
35
29
|
|
|
30
|
+
if (typeof config.delay === 'number') {
|
|
36
31
|
if (i < actions.length - 1) {
|
|
37
|
-
await (0, _utils.wait)(
|
|
32
|
+
await (0, _utils.wait)(config.delay);
|
|
38
33
|
}
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
delete
|
|
43
|
-
return Promise.all(ret);
|
|
37
|
+
delete config.pointerState.activeClickCount;
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
function getPrevTarget(pointerName, state) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { inputDeviceState
|
|
1
|
+
import { inputDeviceState } from '../setup';
|
|
2
|
+
import { PointerTarget, SelectionTarget } from './types';
|
|
2
3
|
export interface PointerMoveAction extends PointerTarget, SelectionTarget {
|
|
3
4
|
pointerName?: string;
|
|
4
5
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { inputDeviceState } from '../setup';
|
|
2
|
+
import type { pointerKey, PointerTarget, SelectionTarget } from './types';
|
|
2
3
|
export interface PointerPressAction extends PointerTarget, SelectionTarget {
|
|
3
4
|
keyDef: pointerKey;
|
|
4
5
|
releasePrevious: boolean;
|
package/dist/pointer/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { keyboardState } from '../keyboard/types';
|
|
2
1
|
import { PointerCoords, MouseButton } from '../utils';
|
|
3
2
|
/**
|
|
4
3
|
* @internal Do not create/alter this by yourself as this type might be subject to changes.
|
|
@@ -34,12 +33,6 @@ export declare type pointerState = {
|
|
|
34
33
|
*/
|
|
35
34
|
pointerId: number;
|
|
36
35
|
};
|
|
37
|
-
export declare type pointerOptions = {
|
|
38
|
-
/** Delay between keystrokes */
|
|
39
|
-
delay: number;
|
|
40
|
-
/** Available pointer keys */
|
|
41
|
-
pointerMap: pointerKey[];
|
|
42
|
-
};
|
|
43
36
|
export interface pointerKey {
|
|
44
37
|
/** Name of the pointer key */
|
|
45
38
|
name: string;
|
|
@@ -66,7 +59,3 @@ export interface SelectionInputRange {
|
|
|
66
59
|
start: number;
|
|
67
60
|
end: number;
|
|
68
61
|
}
|
|
69
|
-
export interface inputDeviceState {
|
|
70
|
-
pointerState: pointerState;
|
|
71
|
-
keyboardState: keyboardState;
|
|
72
|
-
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { click, dblClick, tripleClick, hover, unhover, tab } from '../convenience';
|
|
2
|
+
export { keyboard } from '../keyboard';
|
|
3
|
+
export { copy, cut, paste } from '../clipboard';
|
|
4
|
+
export { pointer } from '../pointer';
|
|
5
|
+
export { clear, deselectOptions, selectOptions, type, upload } from '../utility';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "clear", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _utility.clear;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "click", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _convenience.click;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "copy", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _clipboard.copy;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "cut", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _clipboard.cut;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "dblClick", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _convenience.dblClick;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "deselectOptions", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _utility.deselectOptions;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "hover", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _convenience.hover;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "keyboard", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _keyboard.keyboard;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "paste", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _clipboard.paste;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "pointer", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _pointer.pointer;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "selectOptions", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _utility.selectOptions;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "tab", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _convenience.tab;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "tripleClick", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _convenience.tripleClick;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "type", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _utility.type;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "unhover", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () {
|
|
93
|
+
return _convenience.unhover;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "upload", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _utility.upload;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
var _convenience = require("../convenience");
|
|
104
|
+
|
|
105
|
+
var _keyboard = require("../keyboard");
|
|
106
|
+
|
|
107
|
+
var _clipboard = require("../clipboard");
|
|
108
|
+
|
|
109
|
+
var _pointer = require("../pointer");
|
|
110
|
+
|
|
111
|
+
var _utility = require("../utility");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { keyboardState } from '../keyboard/types';
|
|
2
|
+
import type { pointerState } from '../pointer/types';
|
|
3
|
+
import type { Options } from '../options';
|
|
4
|
+
export interface inputDeviceState {
|
|
5
|
+
pointerState: pointerState;
|
|
6
|
+
keyboardState: keyboardState;
|
|
7
|
+
}
|
|
8
|
+
export interface Config extends Required<Options>, inputDeviceState {
|
|
9
|
+
}
|
|
10
|
+
export declare const Config: unique symbol;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PointerOptions } from '../utils';
|
|
2
|
+
import type { PointerInput } from '../pointer';
|
|
3
|
+
import type { UserEventApi } from '.';
|
|
4
|
+
import { Config } from './config';
|
|
5
|
+
export declare function clear(element: Element): Promise<void>;
|
|
6
|
+
export declare function click(element: Element, options?: Partial<Config>): Promise<void>;
|
|
7
|
+
export declare function copy(options?: Partial<Config>): Promise<DataTransfer | undefined>;
|
|
8
|
+
export declare function cut(options?: Partial<Config>): Promise<DataTransfer | undefined>;
|
|
9
|
+
export declare function dblClick(element: Element, options?: Partial<Config>): Promise<void>;
|
|
10
|
+
export declare function deselectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
|
|
11
|
+
export declare function hover(element: Element, options?: Partial<Config>): Promise<void>;
|
|
12
|
+
export declare function keyboard(text: string, options?: Partial<Config>): Promise<import("../keyboard").keyboardState>;
|
|
13
|
+
export declare function pointer(input: PointerInput, options?: Partial<Config>): Promise<import("../pointer").pointerState>;
|
|
14
|
+
export declare function paste(clipboardData?: DataTransfer | string, options?: Partial<Config>): Promise<void>;
|
|
15
|
+
export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
|
|
16
|
+
export declare function tripleClick(element: Element, options?: Partial<Config>): Promise<void>;
|
|
17
|
+
export declare function type(element: Element, text: string, options?: Partial<Config> & Parameters<UserEventApi['type']>[2]): Promise<void>;
|
|
18
|
+
export declare function unhover(element: Element, options?: PointerOptions): Promise<void>;
|
|
19
|
+
export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: Partial<Config>): Promise<void>;
|
|
20
|
+
export declare function tab(options?: Partial<Config> & Parameters<UserEventApi['tab']>[0]): Promise<void>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clear = clear;
|
|
7
|
+
exports.click = click;
|
|
8
|
+
exports.copy = copy;
|
|
9
|
+
exports.cut = cut;
|
|
10
|
+
exports.dblClick = dblClick;
|
|
11
|
+
exports.deselectOptions = deselectOptions;
|
|
12
|
+
exports.hover = hover;
|
|
13
|
+
exports.keyboard = keyboard;
|
|
14
|
+
exports.paste = paste;
|
|
15
|
+
exports.pointer = pointer;
|
|
16
|
+
exports.selectOptions = selectOptions;
|
|
17
|
+
exports.tab = tab;
|
|
18
|
+
exports.tripleClick = tripleClick;
|
|
19
|
+
exports.type = type;
|
|
20
|
+
exports.unhover = unhover;
|
|
21
|
+
exports.upload = upload;
|
|
22
|
+
|
|
23
|
+
var _setup = require("./setup");
|
|
24
|
+
|
|
25
|
+
var _config = require("./config");
|
|
26
|
+
|
|
27
|
+
function clear(element) {
|
|
28
|
+
return (0, _setup.setupDirect)().clear(element);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function click(element, options = {}) {
|
|
32
|
+
return (0, _setup.setupDirect)(options, element).click(element);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function copy(options = {}) {
|
|
36
|
+
return (0, _setup.setupDirect)(options).copy();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function cut(options = {}) {
|
|
40
|
+
return (0, _setup.setupDirect)(options).cut();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function dblClick(element, options = {}) {
|
|
44
|
+
return (0, _setup.setupDirect)(options).dblClick(element);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function deselectOptions(select, values, options = {}) {
|
|
48
|
+
return (0, _setup.setupDirect)(options).deselectOptions(select, values);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function hover(element, options = {}) {
|
|
52
|
+
return (0, _setup.setupDirect)(options).hover(element);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function keyboard(text, options = {}) {
|
|
56
|
+
const instance = (0, _setup.setupDirect)(options);
|
|
57
|
+
const promise = instance.keyboard(text);
|
|
58
|
+
return promise.then(() => instance[_config.Config].keyboardState);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function pointer(input, options = {}) {
|
|
62
|
+
const instance = (0, _setup.setupDirect)(options);
|
|
63
|
+
const promise = instance.pointer(input);
|
|
64
|
+
return promise.then(() => instance[_config.Config].pointerState);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function paste(clipboardData, options) {
|
|
68
|
+
return (0, _setup.setupDirect)(options).paste(clipboardData);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function selectOptions(select, values, options = {}) {
|
|
72
|
+
return (0, _setup.setupDirect)(options).selectOptions(select, values);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function tripleClick(element, options = {}) {
|
|
76
|
+
return (0, _setup.setupDirect)(options).tripleClick(element);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function type(element, text, options = {}) {
|
|
80
|
+
return (0, _setup.setupDirect)(options, element).type(element, text, options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function unhover(element, options = {}) {
|
|
84
|
+
const instance = (0, _setup.setupDirect)(options);
|
|
85
|
+
instance[_config.Config].pointerState.position.mouse.target = element;
|
|
86
|
+
return instance.unhover(element);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function upload(element, fileOrFiles, options = {}) {
|
|
90
|
+
return (0, _setup.setupDirect)(options).upload(element, fileOrFiles);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function tab(options = {}) {
|
|
94
|
+
return (0, _setup.setupDirect)().tab(options);
|
|
95
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as userEventApi from './api';
|
|
2
|
+
import { setupMain, setupSub } from './setup';
|
|
3
|
+
import { Config, inputDeviceState } from './config';
|
|
4
|
+
import * as directApi from './directApi';
|
|
5
|
+
export type { inputDeviceState };
|
|
6
|
+
export { Config };
|
|
7
|
+
export declare type UserEventApi = typeof userEventApi;
|
|
8
|
+
export declare type UserEvent = UserEventApi & {
|
|
9
|
+
readonly setup: typeof setupSub;
|
|
10
|
+
[Config]: Config;
|
|
11
|
+
};
|
|
12
|
+
export declare const userEvent: {
|
|
13
|
+
readonly setup: typeof setupMain;
|
|
14
|
+
readonly clear: typeof directApi.clear;
|
|
15
|
+
readonly click: typeof directApi.click;
|
|
16
|
+
readonly copy: typeof directApi.copy;
|
|
17
|
+
readonly cut: typeof directApi.cut;
|
|
18
|
+
readonly dblClick: typeof directApi.dblClick;
|
|
19
|
+
readonly deselectOptions: typeof directApi.deselectOptions;
|
|
20
|
+
readonly hover: typeof directApi.hover;
|
|
21
|
+
readonly keyboard: typeof directApi.keyboard;
|
|
22
|
+
readonly pointer: typeof directApi.pointer;
|
|
23
|
+
readonly paste: typeof directApi.paste;
|
|
24
|
+
readonly selectOptions: typeof directApi.selectOptions;
|
|
25
|
+
readonly tripleClick: typeof directApi.tripleClick;
|
|
26
|
+
readonly type: typeof directApi.type;
|
|
27
|
+
readonly unhover: typeof directApi.unhover;
|
|
28
|
+
readonly upload: typeof directApi.upload;
|
|
29
|
+
readonly tab: typeof directApi.tab;
|
|
30
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Config", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _config.Config;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.userEvent = void 0;
|
|
13
|
+
|
|
14
|
+
var _setup = require("./setup");
|
|
15
|
+
|
|
16
|
+
var _config = require("./config");
|
|
17
|
+
|
|
18
|
+
var directApi = _interopRequireWildcard(require("./directApi"));
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
24
|
+
const userEvent = { ...directApi,
|
|
25
|
+
setup: _setup.setupMain
|
|
26
|
+
};
|
|
27
|
+
exports.userEvent = userEvent;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Options } from '../options';
|
|
2
|
+
import type { UserEvent } from './index';
|
|
3
|
+
import { Config } from './config';
|
|
4
|
+
import * as userEventApi from './api';
|
|
5
|
+
/**
|
|
6
|
+
* Start a "session" with userEvent.
|
|
7
|
+
* All APIs returned by this function share an input device state and a default configuration.
|
|
8
|
+
*/
|
|
9
|
+
export declare function setupMain(options?: Options): {
|
|
10
|
+
setup: typeof setupSub;
|
|
11
|
+
[Config]: Config;
|
|
12
|
+
click: typeof userEventApi.click;
|
|
13
|
+
dblClick: typeof userEventApi.dblClick;
|
|
14
|
+
tripleClick: typeof userEventApi.tripleClick;
|
|
15
|
+
hover: typeof userEventApi.hover;
|
|
16
|
+
unhover: typeof userEventApi.unhover;
|
|
17
|
+
tab: typeof userEventApi.tab;
|
|
18
|
+
keyboard: typeof userEventApi.keyboard;
|
|
19
|
+
copy: typeof userEventApi.copy;
|
|
20
|
+
cut: typeof userEventApi.cut;
|
|
21
|
+
paste: typeof userEventApi.paste;
|
|
22
|
+
pointer: typeof userEventApi.pointer;
|
|
23
|
+
clear: typeof userEventApi.clear;
|
|
24
|
+
deselectOptions: typeof userEventApi.deselectOptions;
|
|
25
|
+
selectOptions: typeof userEventApi.selectOptions;
|
|
26
|
+
type: typeof userEventApi.type;
|
|
27
|
+
upload: typeof userEventApi.upload;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Setup in direct call per `userEvent.anyApi()`
|
|
31
|
+
*/
|
|
32
|
+
export declare function setupDirect(options?: Partial<Config>, node?: Node): {
|
|
33
|
+
setup: typeof setupSub;
|
|
34
|
+
[Config]: Config;
|
|
35
|
+
click: typeof userEventApi.click;
|
|
36
|
+
dblClick: typeof userEventApi.dblClick;
|
|
37
|
+
tripleClick: typeof userEventApi.tripleClick;
|
|
38
|
+
hover: typeof userEventApi.hover;
|
|
39
|
+
unhover: typeof userEventApi.unhover;
|
|
40
|
+
tab: typeof userEventApi.tab;
|
|
41
|
+
keyboard: typeof userEventApi.keyboard;
|
|
42
|
+
copy: typeof userEventApi.copy;
|
|
43
|
+
cut: typeof userEventApi.cut;
|
|
44
|
+
paste: typeof userEventApi.paste;
|
|
45
|
+
pointer: typeof userEventApi.pointer;
|
|
46
|
+
clear: typeof userEventApi.clear;
|
|
47
|
+
deselectOptions: typeof userEventApi.deselectOptions;
|
|
48
|
+
selectOptions: typeof userEventApi.selectOptions;
|
|
49
|
+
type: typeof userEventApi.type;
|
|
50
|
+
upload: typeof userEventApi.upload;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Create a set of callbacks with different default settings but the same state.
|
|
54
|
+
*/
|
|
55
|
+
export declare function setupSub(this: UserEvent, options: Options): {
|
|
56
|
+
setup: typeof setupSub;
|
|
57
|
+
[Config]: Config;
|
|
58
|
+
click: typeof userEventApi.click;
|
|
59
|
+
dblClick: typeof userEventApi.dblClick;
|
|
60
|
+
tripleClick: typeof userEventApi.tripleClick;
|
|
61
|
+
hover: typeof userEventApi.hover;
|
|
62
|
+
unhover: typeof userEventApi.unhover;
|
|
63
|
+
tab: typeof userEventApi.tab;
|
|
64
|
+
keyboard: typeof userEventApi.keyboard;
|
|
65
|
+
copy: typeof userEventApi.copy;
|
|
66
|
+
cut: typeof userEventApi.cut;
|
|
67
|
+
paste: typeof userEventApi.paste;
|
|
68
|
+
pointer: typeof userEventApi.pointer;
|
|
69
|
+
clear: typeof userEventApi.clear;
|
|
70
|
+
deselectOptions: typeof userEventApi.deselectOptions;
|
|
71
|
+
selectOptions: typeof userEventApi.selectOptions;
|
|
72
|
+
type: typeof userEventApi.type;
|
|
73
|
+
upload: typeof userEventApi.upload;
|
|
74
|
+
};
|