@testing-library/user-event 14.0.0-alpha.1 → 14.0.0-alpha.13
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/{src/clear.d.ts → clear.d.ts} +0 -0
- package/dist/clear.js +14 -27
- package/dist/{src/click.d.ts → click.d.ts} +3 -2
- package/dist/click.js +23 -7
- package/dist/document/index.d.ts +10 -0
- package/dist/document/index.js +8 -10
- package/dist/document/interceptor.d.ts +15 -0
- package/dist/document/interceptor.js +7 -4
- package/dist/document/selection.d.ts +27 -0
- package/dist/document/selection.js +51 -28
- package/dist/{src/document → document}/value.d.ts +5 -1
- package/dist/document/value.js +27 -6
- package/dist/{src/hover.d.ts → hover.d.ts} +2 -2
- package/dist/hover.js +2 -2
- package/dist/{src/index.d.ts → index.d.ts} +0 -2
- package/dist/index.js +0 -8
- package/dist/{src/keyboard → keyboard}/getEventProps.d.ts +0 -2
- package/dist/keyboard/getEventProps.js +1 -7
- package/dist/{src/keyboard → keyboard}/getNextKeyDef.d.ts +0 -1
- package/dist/keyboard/getNextKeyDef.js +2 -32
- package/dist/{src/keyboard → keyboard}/index.d.ts +0 -1
- package/dist/keyboard/index.js +0 -8
- package/dist/{src/keyboard → keyboard}/keyMap.d.ts +0 -0
- package/dist/keyboard/keyMap.js +26 -46
- package/dist/{src/keyboard → keyboard}/keyboardImplementation.d.ts +0 -0
- package/dist/keyboard/keyboardImplementation.js +15 -17
- package/dist/{src/keyboard → keyboard}/plugins/arrow.d.ts +0 -0
- package/dist/keyboard/plugins/arrow.js +7 -12
- package/dist/{src/keyboard → keyboard}/plugins/character.d.ts +0 -0
- package/dist/keyboard/plugins/character.js +27 -45
- package/dist/keyboard/plugins/combination.d.ts +5 -0
- package/dist/keyboard/plugins/combination.js +17 -0
- package/dist/{src/keyboard → keyboard}/plugins/control.d.ts +0 -0
- package/dist/keyboard/plugins/control.js +4 -12
- package/dist/{src/keyboard → keyboard}/plugins/functional.d.ts +0 -0
- package/dist/keyboard/plugins/functional.js +23 -11
- package/dist/{src/keyboard → keyboard}/plugins/index.d.ts +0 -1
- package/dist/keyboard/plugins/index.js +4 -11
- package/dist/{src/keyboard → keyboard}/shared/fireChangeForInputTimeIfValid.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/shared/index.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/types.d.ts +0 -2
- package/dist/paste.d.ts +6 -0
- package/dist/paste.js +40 -43
- package/dist/{src/pointer → pointer}/index.d.ts +0 -0
- package/dist/{src/pointer → pointer}/keyMap.d.ts +0 -0
- package/dist/{src/pointer → pointer}/parseKeyDef.d.ts +0 -0
- package/dist/{src/pointer → pointer}/pointerAction.d.ts +2 -6
- package/dist/pointer/pointerAction.js +2 -26
- package/dist/pointer/pointerMove.d.ts +5 -0
- package/dist/pointer/pointerMove.js +49 -5
- package/dist/pointer/pointerPress.d.ts +7 -0
- package/dist/pointer/pointerPress.js +135 -29
- package/dist/pointer/resolveSelectionTarget.d.ts +5 -0
- package/dist/pointer/resolveSelectionTarget.js +75 -0
- package/dist/{src/pointer → pointer}/types.d.ts +18 -4
- package/dist/{src/selectOptions.d.ts → selectOptions.d.ts} +2 -2
- package/dist/selectOptions.js +25 -26
- package/dist/{src/setup.d.ts → setup.d.ts} +5 -2
- package/dist/setup.js +32 -21
- package/dist/tab.d.ts +5 -0
- package/dist/tab.js +3 -132
- package/dist/{src/type.d.ts → type.d.ts} +0 -0
- package/dist/type.js +3 -19
- package/dist/{src/upload.d.ts → upload.d.ts} +0 -1
- package/dist/upload.js +1 -1
- package/dist/{src/utils → utils}/click/isClickableInput.d.ts +0 -0
- package/dist/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/utils/dataTransfer/Blob.js +21 -0
- package/dist/utils/dataTransfer/Clipboard.d.ts +7 -0
- package/dist/utils/dataTransfer/Clipboard.js +143 -0
- package/dist/utils/dataTransfer/DataTransfer.d.ts +1 -0
- package/dist/utils/dataTransfer/DataTransfer.js +143 -0
- package/dist/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/utils/dataTransfer/FileList.js +13 -0
- package/dist/{src/utils → utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/utils/edit/calculateNewValue.d.ts +14 -0
- package/dist/utils/edit/calculateNewValue.js +19 -21
- package/dist/utils/edit/editInputElement.d.ts +16 -0
- package/dist/utils/edit/editInputElement.js +53 -0
- package/dist/{src/utils → utils}/edit/getValue.d.ts +0 -0
- package/dist/utils/edit/getValue.js +1 -3
- package/dist/utils/edit/isContentEditable.d.ts +7 -0
- package/dist/utils/edit/isContentEditable.js +14 -0
- package/dist/{src/utils → utils}/edit/isEditable.d.ts +1 -0
- package/dist/{src/utils → utils}/edit/isValidDateValue.d.ts +0 -0
- package/dist/{src/utils → utils}/edit/isValidInputTimeValue.d.ts +0 -0
- package/dist/{src/utils → utils}/edit/maxLength.d.ts +0 -0
- package/dist/utils/edit/prepareInput.d.ts +7 -0
- package/dist/utils/edit/prepareInput.js +77 -0
- package/dist/{src/utils → utils}/focus/blur.d.ts +0 -0
- package/dist/{src/utils → utils}/focus/focus.d.ts +0 -0
- package/dist/utils/focus/focus.js +3 -0
- package/dist/{src/utils → utils}/focus/getActiveElement.d.ts +0 -0
- package/dist/utils/focus/getTabDestination.d.ts +1 -0
- package/dist/utils/focus/getTabDestination.js +71 -0
- package/dist/{src/utils → utils}/focus/isFocusable.d.ts +0 -0
- package/dist/utils/focus/selectAll.d.ts +5 -0
- package/dist/utils/focus/selectAll.js +51 -0
- package/dist/utils/focus/selection.d.ts +42 -0
- package/dist/utils/focus/selection.js +190 -0
- package/dist/{src/utils → utils}/focus/selector.d.ts +0 -0
- package/dist/{src/utils → utils}/index.d.ts +9 -5
- package/dist/utils/index.js +98 -46
- package/dist/{src/utils → utils}/keyDef/readNextDescriptor.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/eventWrapper.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/findClosest.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/hasFormSubmit.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/hasPointerEvents.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isDescendantOrSelf.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isDisabled.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isElementType.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isVisible.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/wait.d.ts +0 -0
- package/dist/{src/utils → utils}/pointer/firePointerEvents.d.ts +13 -11
- package/dist/utils/pointer/firePointerEvents.js +62 -5
- package/dist/{src/utils → utils}/pointer/mouseButtons.d.ts +0 -0
- package/package.json +2 -2
- package/dist/document/applyNative.js +0 -28
- package/dist/keyboard/specialCharMap.js +0 -30
- package/dist/src/document/applyNative.d.ts +0 -8
- package/dist/src/document/index.d.ts +0 -10
- package/dist/src/document/interceptor.d.ts +0 -5
- package/dist/src/document/selection.d.ts +0 -18
- package/dist/src/keyboard/specialCharMap.d.ts +0 -22
- package/dist/src/paste.d.ts +0 -7
- package/dist/src/pointer/pointerMove.d.ts +0 -5
- package/dist/src/pointer/pointerPress.d.ts +0 -7
- package/dist/src/tab.d.ts +0 -6
- package/dist/src/utils/edit/calculateNewValue.d.ts +0 -7
- package/dist/src/utils/edit/cursorPosition.d.ts +0 -2
- package/dist/src/utils/edit/fireInputEvent.d.ts +0 -8
- package/dist/src/utils/edit/isContentEditable.d.ts +0 -3
- package/dist/src/utils/edit/selectionRange.d.ts +0 -5
- package/dist/src/utils/misc/isDocument.d.ts +0 -1
- package/dist/src/utils/pointer/fakeEvent.d.ts +0 -16
- package/dist/tests/_helpers/custom-element.d.ts +0 -8
- package/dist/tests/_helpers/utils.d.ts +0 -73
- package/dist/tests/_setup-env.d.ts +0 -1
- package/dist/tests/clear.d.ts +0 -1
- package/dist/tests/click/click.d.ts +0 -1
- package/dist/tests/click/dblclick.d.ts +0 -1
- package/dist/tests/document/index.d.ts +0 -1
- package/dist/tests/document/selectionRange.d.ts +0 -1
- package/dist/tests/hover/hover.d.ts +0 -1
- package/dist/tests/hover/unhover.d.ts +0 -1
- package/dist/tests/keyboard/getNextKeyDef.d.ts +0 -1
- package/dist/tests/keyboard/index.d.ts +0 -1
- package/dist/tests/keyboard/keyboardImplementation.d.ts +0 -1
- package/dist/tests/keyboard/plugin/arrow.d.ts +0 -1
- package/dist/tests/keyboard/plugin/character.d.ts +0 -1
- package/dist/tests/keyboard/plugin/control.d.ts +0 -1
- package/dist/tests/keyboard/plugin/functional.d.ts +0 -1
- package/dist/tests/keyboard/shared/fireInputEvent.d.ts +0 -1
- package/dist/tests/paste.d.ts +0 -1
- package/dist/tests/pointer/index.d.ts +0 -1
- package/dist/tests/react/keyboard.d.ts +0 -1
- package/dist/tests/react/type.d.ts +0 -1
- package/dist/tests/selectOptions/deselect.d.ts +0 -1
- package/dist/tests/selectOptions/select.d.ts +0 -1
- package/dist/tests/setup.d.ts +0 -10
- package/dist/tests/tab.d.ts +0 -1
- package/dist/tests/type/index.d.ts +0 -1
- package/dist/tests/type/modifiers.d.ts +0 -1
- package/dist/tests/upload.d.ts +0 -1
- package/dist/tests/utils/edit/calculateNewValue.d.ts +0 -1
- package/dist/tests/utils/edit/isContentEditable.d.ts +0 -1
- package/dist/tests/utils/focus/blur.d.ts +0 -1
- package/dist/tests/utils/focus/focus.d.ts +0 -1
- package/dist/tests/utils/misc/hasPointerEvents.d.ts +0 -1
- package/dist/tests/utils/misc/isDescendantOrSelf.d.ts +0 -1
- package/dist/tests/utils/misc/isElementType.d.ts +0 -1
- package/dist/tests/utils/misc/isVisible.d.ts +0 -1
- package/dist/utils/edit/cursorPosition.js +0 -35
- package/dist/utils/edit/fireInputEvent.js +0 -55
- package/dist/utils/edit/selectionRange.js +0 -64
- package/dist/utils/misc/dom-helpers.d.ts +0 -3
- package/dist/utils/misc/isDocument.js +0 -10
- package/dist/utils/pointer/fakeEvent.js +0 -82
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.specialCharMap = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated This list of strings with special meaning is no longer necessary
|
|
10
|
-
* as we've introduced a standardized way to describe any keystroke for `userEvent`.
|
|
11
|
-
* @see https://testing-library.com/docs/ecosystem-user-event#keyboardtext-options
|
|
12
|
-
*/
|
|
13
|
-
const specialCharMap = {
|
|
14
|
-
arrowLeft: '{arrowleft}',
|
|
15
|
-
arrowRight: '{arrowright}',
|
|
16
|
-
arrowDown: '{arrowdown}',
|
|
17
|
-
arrowUp: '{arrowup}',
|
|
18
|
-
enter: '{enter}',
|
|
19
|
-
escape: '{esc}',
|
|
20
|
-
delete: '{del}',
|
|
21
|
-
backspace: '{backspace}',
|
|
22
|
-
home: '{home}',
|
|
23
|
-
end: '{end}',
|
|
24
|
-
selectAll: '{selectall}',
|
|
25
|
-
space: '{space}',
|
|
26
|
-
whitespace: ' ',
|
|
27
|
-
pageUp: '{pageUp}',
|
|
28
|
-
pageDown: '{pageDown}'
|
|
29
|
-
};
|
|
30
|
-
exports.specialCharMap = specialCharMap;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React tracks the changes on element properties.
|
|
3
|
-
* This workaround tries to alter the DOM element without React noticing,
|
|
4
|
-
* so that it later picks up the change.
|
|
5
|
-
*
|
|
6
|
-
* @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
|
|
7
|
-
*/
|
|
8
|
-
export declare function applyNative<T extends Element, P extends keyof T>(element: T, propName: P, propValue: T[P]): void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare const isPrepared: unique symbol;
|
|
2
|
-
declare global {
|
|
3
|
-
interface Node {
|
|
4
|
-
[isPrepared]?: typeof isPrepared;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export declare function prepareDocument(document: Document): void;
|
|
8
|
-
export { applyNative } from './applyNative';
|
|
9
|
-
export { getUIValue, setUIValue } from './value';
|
|
10
|
-
export { getUISelection, hasUISelection, setUISelection } from './selection';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
declare type anyFunc = (...a: any[]) => any;
|
|
2
|
-
declare type Params<Prop> = Prop extends anyFunc ? Parameters<Prop> : [Prop];
|
|
3
|
-
declare type ImplReturn<Prop> = Prop extends anyFunc ? Parameters<Prop> : Prop;
|
|
4
|
-
export declare function prepareInterceptor<ElementType extends Element, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => ImplReturn<ElementType[PropName]>): void;
|
|
5
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare const UISelection: unique symbol;
|
|
2
|
-
declare global {
|
|
3
|
-
interface Element {
|
|
4
|
-
[UISelection]?: {
|
|
5
|
-
start: number;
|
|
6
|
-
end: number;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export declare function prepareSelectionInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
11
|
-
export declare function setUISelection(element: HTMLInputElement | HTMLTextAreaElement, start: number, end: number): void;
|
|
12
|
-
export declare function getUISelection(element: HTMLInputElement | HTMLTextAreaElement): {
|
|
13
|
-
selectionStart: number | null;
|
|
14
|
-
selectionEnd: number | null;
|
|
15
|
-
};
|
|
16
|
-
export declare function clearUISelection(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
17
|
-
export declare function hasUISelection(element: HTMLInputElement | HTMLTextAreaElement): boolean;
|
|
18
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated This list of strings with special meaning is no longer necessary
|
|
3
|
-
* as we've introduced a standardized way to describe any keystroke for `userEvent`.
|
|
4
|
-
* @see https://testing-library.com/docs/ecosystem-user-event#keyboardtext-options
|
|
5
|
-
*/
|
|
6
|
-
export declare const specialCharMap: {
|
|
7
|
-
readonly arrowLeft: "{arrowleft}";
|
|
8
|
-
readonly arrowRight: "{arrowright}";
|
|
9
|
-
readonly arrowDown: "{arrowdown}";
|
|
10
|
-
readonly arrowUp: "{arrowup}";
|
|
11
|
-
readonly enter: "{enter}";
|
|
12
|
-
readonly escape: "{esc}";
|
|
13
|
-
readonly delete: "{del}";
|
|
14
|
-
readonly backspace: "{backspace}";
|
|
15
|
-
readonly home: "{home}";
|
|
16
|
-
readonly end: "{end}";
|
|
17
|
-
readonly selectAll: "{selectall}";
|
|
18
|
-
readonly space: "{space}";
|
|
19
|
-
readonly whitespace: " ";
|
|
20
|
-
readonly pageUp: "{pageUp}";
|
|
21
|
-
readonly pageDown: "{pageDown}";
|
|
22
|
-
};
|
package/dist/src/paste.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { UserEvent } from './setup';
|
|
2
|
-
interface pasteOptions {
|
|
3
|
-
initialSelectionStart?: number;
|
|
4
|
-
initialSelectionEnd?: number;
|
|
5
|
-
}
|
|
6
|
-
export declare function paste(this: UserEvent, element: HTMLElement, text: string, init?: ClipboardEventInit, { initialSelectionStart, initialSelectionEnd }?: pasteOptions): void;
|
|
7
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { inputDeviceState, PointerTarget } from './types';
|
|
2
|
-
export interface PointerMoveAction extends PointerTarget {
|
|
3
|
-
pointerName?: string;
|
|
4
|
-
}
|
|
5
|
-
export declare function pointerMove({ pointerName, target, coords }: PointerMoveAction, { pointerState, keyboardState }: inputDeviceState): Promise<void>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { inputDeviceState, pointerKey, PointerTarget } from './types';
|
|
2
|
-
export interface PointerPressAction extends PointerTarget {
|
|
3
|
-
keyDef: pointerKey;
|
|
4
|
-
releasePrevious: boolean;
|
|
5
|
-
releaseSelf: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function pointerPress({ keyDef, releasePrevious, releaseSelf, target, coords }: PointerPressAction, state: inputDeviceState): Promise<void>;
|
package/dist/src/tab.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare function calculateNewValue(newEntry: string, element: HTMLElement, value?: string, selectionRange?: {
|
|
2
|
-
selectionStart: number | null;
|
|
3
|
-
selectionEnd: number | null;
|
|
4
|
-
}, deleteContent?: 'backward' | 'forward'): {
|
|
5
|
-
newValue: string;
|
|
6
|
-
newSelectionStart: number;
|
|
7
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { fireEvent } from '@testing-library/dom';
|
|
2
|
-
export declare function fireInputEvent(element: HTMLElement, { newValue, newSelectionStart, eventOverrides, }: {
|
|
3
|
-
newValue: string;
|
|
4
|
-
newSelectionStart: number;
|
|
5
|
-
eventOverrides: Partial<Parameters<typeof fireEvent>[1]> & {
|
|
6
|
-
[k: string]: unknown;
|
|
7
|
-
};
|
|
8
|
-
}): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isDocument(el: Document | Element): el is Document;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface FakeEventInit extends MouseEventInit, PointerEventInit {
|
|
2
|
-
x?: number;
|
|
3
|
-
y?: number;
|
|
4
|
-
clientX?: number;
|
|
5
|
-
clientY?: number;
|
|
6
|
-
offsetX?: number;
|
|
7
|
-
offsetY?: number;
|
|
8
|
-
pageX?: number;
|
|
9
|
-
pageY?: number;
|
|
10
|
-
}
|
|
11
|
-
export declare class FakeMouseEvent extends MouseEvent {
|
|
12
|
-
constructor(type: string, init: FakeEventInit);
|
|
13
|
-
}
|
|
14
|
-
export declare class FakePointerEvent extends MouseEvent {
|
|
15
|
-
constructor(type: string, init: FakeEventInit);
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
declare const observed: string[];
|
|
2
|
-
declare class CustomEl extends HTMLElement {
|
|
3
|
-
static getObservedAttributes(): string[];
|
|
4
|
-
$input: HTMLInputElement | null;
|
|
5
|
-
connectedCallback(): void;
|
|
6
|
-
attributeChangedCallback(name: any, oldVal: any, newVal: any): void;
|
|
7
|
-
render(name: any, value: any): void;
|
|
8
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
declare type EventHandlers = Record<string, EventListener>;
|
|
2
|
-
declare type HTMLCollection<Elements extends Array<Element>> = Elements & {
|
|
3
|
-
item<N extends number>(i: N): Elements[N];
|
|
4
|
-
};
|
|
5
|
-
declare function setup<Elements extends Element | Element[] = HTMLElement>(ui: string, { eventHandlers, }?: {
|
|
6
|
-
eventHandlers?: EventHandlers;
|
|
7
|
-
}): {
|
|
8
|
-
getEventSnapshot: () => {
|
|
9
|
-
snapshot: string;
|
|
10
|
-
};
|
|
11
|
-
getClickEventsSnapshot: () => {
|
|
12
|
-
snapshot: string;
|
|
13
|
-
};
|
|
14
|
-
clearEventCalls: () => void;
|
|
15
|
-
getEvents: (type?: string | undefined) => Event[];
|
|
16
|
-
eventWasFired: (eventType: string) => boolean;
|
|
17
|
-
element: (Elements extends Element[] ? Elements : [Elements])[0];
|
|
18
|
-
elements: HTMLCollection<Elements extends Element[] ? Elements : [Elements]>;
|
|
19
|
-
};
|
|
20
|
-
declare function setupSelect({ disabled, disabledOptions, multiple, pointerEvents, }?: {
|
|
21
|
-
disabled?: boolean | undefined;
|
|
22
|
-
disabledOptions?: boolean | undefined;
|
|
23
|
-
multiple?: boolean | undefined;
|
|
24
|
-
pointerEvents?: string | undefined;
|
|
25
|
-
}): {
|
|
26
|
-
form: HTMLFormElement;
|
|
27
|
-
select: HTMLSelectElement;
|
|
28
|
-
options: HTMLOptionElement[];
|
|
29
|
-
getEventSnapshot: () => {
|
|
30
|
-
snapshot: string;
|
|
31
|
-
};
|
|
32
|
-
getClickEventsSnapshot: () => {
|
|
33
|
-
snapshot: string;
|
|
34
|
-
};
|
|
35
|
-
clearEventCalls: () => void;
|
|
36
|
-
getEvents: (type?: string | undefined) => Event[];
|
|
37
|
-
eventWasFired: (eventType: string) => boolean;
|
|
38
|
-
};
|
|
39
|
-
declare function setupListbox(): {
|
|
40
|
-
listbox: HTMLUListElement;
|
|
41
|
-
options: HTMLElement[];
|
|
42
|
-
getEventSnapshot: () => {
|
|
43
|
-
snapshot: string;
|
|
44
|
-
};
|
|
45
|
-
getClickEventsSnapshot: () => {
|
|
46
|
-
snapshot: string;
|
|
47
|
-
};
|
|
48
|
-
clearEventCalls: () => void;
|
|
49
|
-
getEvents: (type?: string | undefined) => Event[];
|
|
50
|
-
eventWasFired: (eventType: string) => boolean;
|
|
51
|
-
};
|
|
52
|
-
declare function addEventListener(el: EventTarget, type: string, listener: EventListener, options?: AddEventListenerOptions): void;
|
|
53
|
-
declare type TestData = {
|
|
54
|
-
handled?: boolean;
|
|
55
|
-
before?: Element;
|
|
56
|
-
after?: Element;
|
|
57
|
-
};
|
|
58
|
-
declare function addListeners(element: Element & {
|
|
59
|
-
testData?: TestData;
|
|
60
|
-
}, { eventHandlers, }?: {
|
|
61
|
-
eventHandlers?: EventHandlers;
|
|
62
|
-
}): {
|
|
63
|
-
getEventSnapshot: () => {
|
|
64
|
-
snapshot: string;
|
|
65
|
-
};
|
|
66
|
-
getClickEventsSnapshot: () => {
|
|
67
|
-
snapshot: string;
|
|
68
|
-
};
|
|
69
|
-
clearEventCalls: () => void;
|
|
70
|
-
getEvents: (type?: string | undefined) => Event[];
|
|
71
|
-
eventWasFired: (eventType: string) => boolean;
|
|
72
|
-
};
|
|
73
|
-
export { setup, setupSelect, setupListbox, addEventListener, addListeners };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tests/clear.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tests/paste.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tests/setup.d.ts
DELETED
package/dist/tests/tab.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tests/upload.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isCursorAtEnd = isCursorAtEnd;
|
|
7
|
-
exports.isCursorAtStart = isCursorAtStart;
|
|
8
|
-
|
|
9
|
-
var _selectionRange = require("./selectionRange");
|
|
10
|
-
|
|
11
|
-
var _getValue2 = require("./getValue");
|
|
12
|
-
|
|
13
|
-
function isCursorAtEnd(element) {
|
|
14
|
-
var _getValue;
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
selectionStart,
|
|
18
|
-
selectionEnd
|
|
19
|
-
} = (0, _selectionRange.getSelectionRange)(element);
|
|
20
|
-
return selectionStart === selectionEnd && (selectionStart != null ? selectionStart :
|
|
21
|
-
/* istanbul ignore next */
|
|
22
|
-
0) === ((_getValue = (0, _getValue2.getValue)(element)) != null ? _getValue :
|
|
23
|
-
/* istanbul ignore next */
|
|
24
|
-
'').length;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function isCursorAtStart(element) {
|
|
28
|
-
const {
|
|
29
|
-
selectionStart,
|
|
30
|
-
selectionEnd
|
|
31
|
-
} = (0, _selectionRange.getSelectionRange)(element);
|
|
32
|
-
return selectionStart === selectionEnd && (selectionStart != null ? selectionStart :
|
|
33
|
-
/* istanbul ignore next */
|
|
34
|
-
0) === 0;
|
|
35
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fireInputEvent = fireInputEvent;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _isElementType = require("../misc/isElementType");
|
|
11
|
-
|
|
12
|
-
var _document = require("../../document");
|
|
13
|
-
|
|
14
|
-
var _isContentEditable = require("./isContentEditable");
|
|
15
|
-
|
|
16
|
-
var _selectionRange = require("./selectionRange");
|
|
17
|
-
|
|
18
|
-
function fireInputEvent(element, {
|
|
19
|
-
newValue,
|
|
20
|
-
newSelectionStart,
|
|
21
|
-
eventOverrides
|
|
22
|
-
}) {
|
|
23
|
-
// apply the changes before firing the input event, so that input handlers can access the altered dom and selection
|
|
24
|
-
if ((0, _isContentEditable.isContentEditable)(element)) {
|
|
25
|
-
(0, _document.applyNative)(element, 'textContent', newValue);
|
|
26
|
-
} else
|
|
27
|
-
/* istanbul ignore else */
|
|
28
|
-
if ((0, _isElementType.isElementType)(element, ['input', 'textarea'])) {
|
|
29
|
-
(0, _document.setUIValue)(element, newValue);
|
|
30
|
-
} else {
|
|
31
|
-
// TODO: properly type guard
|
|
32
|
-
throw new Error('Invalid Element');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
setSelectionRangeAfterInput(element, newSelectionStart);
|
|
36
|
-
|
|
37
|
-
_dom.fireEvent.input(element, { ...eventOverrides
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
setSelectionRangeAfterInputHandler(element, newSelectionStart);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function setSelectionRangeAfterInput(element, newSelectionStart) {
|
|
44
|
-
(0, _selectionRange.setSelectionRange)(element, newSelectionStart, newSelectionStart);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function setSelectionRangeAfterInputHandler(element, newSelectionStart) {
|
|
48
|
-
// On controlled inputs the selection changes without a call to
|
|
49
|
-
// either the `value` setter or the `setSelectionRange` method.
|
|
50
|
-
// So if our tracked position for UI still exists and derives from a valid selectionStart,
|
|
51
|
-
// the cursor was moved due to an input being controlled.
|
|
52
|
-
if ((0, _isElementType.isElementType)(element, ['input', 'textarea']) && typeof element.selectionStart === 'number' && element.selectionStart !== newSelectionStart && (0, _document.hasUISelection)(element)) {
|
|
53
|
-
(0, _selectionRange.setSelectionRange)(element, newSelectionStart, newSelectionStart);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getSelectionRange = getSelectionRange;
|
|
7
|
-
exports.setSelectionRange = setSelectionRange;
|
|
8
|
-
|
|
9
|
-
var _isElementType = require("../misc/isElementType");
|
|
10
|
-
|
|
11
|
-
var _document = require("../../document");
|
|
12
|
-
|
|
13
|
-
function getSelectionRange(element) {
|
|
14
|
-
if ((0, _isElementType.isElementType)(element, ['input', 'textarea'])) {
|
|
15
|
-
return (0, _document.getUISelection)(element);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const selection = element.ownerDocument.getSelection(); // there should be no editing if the focusNode is outside of element
|
|
19
|
-
// TODO: properly handle selection ranges
|
|
20
|
-
|
|
21
|
-
if (selection != null && selection.rangeCount && element.contains(selection.focusNode)) {
|
|
22
|
-
const range = selection.getRangeAt(0);
|
|
23
|
-
return {
|
|
24
|
-
selectionStart: range.startOffset,
|
|
25
|
-
selectionEnd: range.endOffset
|
|
26
|
-
};
|
|
27
|
-
} else {
|
|
28
|
-
return {
|
|
29
|
-
selectionStart: null,
|
|
30
|
-
selectionEnd: null
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function setSelectionRange(element, newSelectionStart, newSelectionEnd) {
|
|
36
|
-
if ((0, _isElementType.isElementType)(element, ['input', 'textarea'])) {
|
|
37
|
-
return (0, _document.setUISelection)(element, newSelectionStart, newSelectionEnd);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
selectionStart,
|
|
42
|
-
selectionEnd
|
|
43
|
-
} = getSelectionRange(element); // Prevent unnecessary select events
|
|
44
|
-
// istanbul ignore next
|
|
45
|
-
|
|
46
|
-
if (selectionStart === newSelectionStart && selectionEnd === newSelectionEnd) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const range = element.ownerDocument.createRange();
|
|
51
|
-
range.selectNodeContents(element); // istanbul ignore else
|
|
52
|
-
|
|
53
|
-
if (element.firstChild) {
|
|
54
|
-
range.setStart(element.firstChild, newSelectionStart);
|
|
55
|
-
range.setEnd(element.firstChild, newSelectionEnd);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const selection = element.ownerDocument.getSelection(); // istanbul ignore else
|
|
59
|
-
|
|
60
|
-
if (selection) {
|
|
61
|
-
selection.removeAllRanges();
|
|
62
|
-
selection.addRange(range);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.FakePointerEvent = exports.FakeMouseEvent = void 0;
|
|
7
|
-
|
|
8
|
-
// See : https://github.com/testing-library/react-testing-library/issues/268
|
|
9
|
-
function assignProps(obj, props) {
|
|
10
|
-
for (const [key, value] of Object.entries(props)) {
|
|
11
|
-
Object.defineProperty(obj, key, {
|
|
12
|
-
get: () => value
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function assignPositionInit(obj, {
|
|
18
|
-
x,
|
|
19
|
-
y,
|
|
20
|
-
clientX,
|
|
21
|
-
clientY,
|
|
22
|
-
offsetX,
|
|
23
|
-
offsetY,
|
|
24
|
-
pageX,
|
|
25
|
-
pageY
|
|
26
|
-
}) {
|
|
27
|
-
assignProps(obj, {
|
|
28
|
-
x,
|
|
29
|
-
y,
|
|
30
|
-
clientX,
|
|
31
|
-
clientY,
|
|
32
|
-
offsetX,
|
|
33
|
-
offsetY,
|
|
34
|
-
pageX,
|
|
35
|
-
pageY
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function assignPointerInit(obj, {
|
|
40
|
-
isPrimary,
|
|
41
|
-
pointerId,
|
|
42
|
-
pointerType
|
|
43
|
-
}) {
|
|
44
|
-
assignProps(obj, {
|
|
45
|
-
isPrimary,
|
|
46
|
-
pointerId,
|
|
47
|
-
pointerType
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const notBubbling = ['mouseenter', 'mouseleave', 'pointerenter', 'pointerleave'];
|
|
52
|
-
|
|
53
|
-
function getInitDefaults(type, init) {
|
|
54
|
-
return {
|
|
55
|
-
bubbles: !notBubbling.includes(type),
|
|
56
|
-
cancelable: true,
|
|
57
|
-
composed: true,
|
|
58
|
-
...init
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
class FakeMouseEvent extends MouseEvent {
|
|
63
|
-
constructor(type, init) {
|
|
64
|
-
super(type, getInitDefaults(type, init));
|
|
65
|
-
assignPositionInit(this, init);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
} // Should extend PointerEvent, but... https://github.com/jsdom/jsdom/issues/2527
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
exports.FakeMouseEvent = FakeMouseEvent;
|
|
72
|
-
|
|
73
|
-
class FakePointerEvent extends MouseEvent {
|
|
74
|
-
constructor(type, init) {
|
|
75
|
-
super(type, getInitDefaults(type, init));
|
|
76
|
-
assignPositionInit(this, init);
|
|
77
|
-
assignPointerInit(this, init);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
exports.FakePointerEvent = FakePointerEvent;
|