diff --git a/src/utils/index.ts b/src/utils/index.ts index 5a76fce6..d5ace066 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -32,6 +32,5 @@ export * from './misc/wait' export * from './misc/hasPointerEvents' export * from './misc/hasFormSubmit' -export * from './pointer/fakeEvent' export * from './pointer/firePointerEvents' export * from './pointer/mouseButtons' diff --git a/src/utils/pointer/dom-events.d.ts b/src/utils/pointer/dom-events.d.ts new file mode 100644 index 00000000..fa78d697 --- /dev/null +++ b/src/utils/pointer/dom-events.d.ts @@ -0,0 +1,3 @@ +declare module '@testing-library/dom/dist/event-map' { + export const eventMap: Record +} diff --git a/src/utils/pointer/fakeEvent.ts b/src/utils/pointer/fakeEvent.ts deleted file mode 100644 index 138ec1a1..00000000 --- a/src/utils/pointer/fakeEvent.ts +++ /dev/null @@ -1,100 +0,0 @@ -// See : https://github.com/testing-library/react-testing-library/issues/268 - -export interface PointerCoords { - x?: number - y?: number - clientX?: number - clientY?: number - offsetX?: number - offsetY?: number - pageX?: number - pageY?: number - screenX?: number - screenY?: number -} - -export interface FakePointerEventInit - extends MouseEventInit, - PointerEventInit, - PointerCoords {} - -function assignProps( - obj: MouseEvent | PointerEvent, - props: FakePointerEventInit, -) { - for (const [key, value] of Object.entries(props)) { - Object.defineProperty(obj, key, {get: () => value}) - } -} - -function assignPositionInit( - obj: MouseEvent | PointerEvent, - { - x, - y, - clientX, - clientY, - offsetX, - offsetY, - pageX, - pageY, - screenX, - screenY, - }: FakePointerEventInit, -) { - assignProps(obj, { - /* istanbul ignore start */ - x: x ?? clientX ?? 0, - y: y ?? clientY ?? 0, - clientX: x ?? clientX ?? 0, - clientY: y ?? clientY ?? 0, - offsetX: offsetX ?? 0, - offsetY: offsetY ?? 0, - pageX: pageX ?? 0, - pageY: pageY ?? 0, - screenX: screenX ?? 0, - screenY: screenY ?? 0, - /* istanbul ignore end */ - }) -} - -function assignPointerInit( - obj: MouseEvent | PointerEvent, - {isPrimary, pointerId, pointerType}: FakePointerEventInit, -) { - assignProps(obj, { - isPrimary, - pointerId, - pointerType, - }) -} - -const notBubbling = ['mouseenter', 'mouseleave', 'pointerenter', 'pointerleave'] - -function getInitDefaults( - type: string, - init: FakePointerEventInit, -): FakePointerEventInit { - return { - bubbles: !notBubbling.includes(type), - cancelable: true, - composed: true, - ...init, - } -} - -export class FakeMouseEvent extends MouseEvent { - constructor(type: string, init: FakePointerEventInit) { - super(type, getInitDefaults(type, init)) - assignPositionInit(this, init) - } -} - -// Should extend PointerEvent, but... https://github.com/jsdom/jsdom/issues/2527 -export class FakePointerEvent extends MouseEvent { - constructor(type: string, init: FakePointerEventInit) { - super(type, getInitDefaults(type, init)) - assignPositionInit(this, init) - assignPointerInit(this, init) - } -} diff --git a/src/utils/pointer/firePointerEvents.ts b/src/utils/pointer/firePointerEvents.ts index 07f3999d..418c6bea 100644 --- a/src/utils/pointer/firePointerEvents.ts +++ b/src/utils/pointer/firePointerEvents.ts @@ -1,12 +1,7 @@ -import {fireEvent} from '@testing-library/dom' +import {createEvent, fireEvent} from '@testing-library/dom' +import {eventMap} from '@testing-library/dom/dist/event-map' import type {pointerState} from '../../pointer/types' import type {keyboardState} from '../../keyboard/types' -import { - FakeMouseEvent, - FakePointerEvent, - FakePointerEventInit, - PointerCoords, -} from './fakeEvent' import {getMouseButton, getMouseButtons, MouseButton} from './mouseButtons' export function firePointerEvent( @@ -32,19 +27,14 @@ export function firePointerEvent( clickCount?: number }, ) { - const Event = - type === 'click' || type.startsWith('mouse') - ? FakeMouseEvent - : FakePointerEvent - - const init: FakePointerEventInit = { + const init: MouseEventInit & PointerEventInit = { ...coords, altKey: keyboardState.modifiers.alt, ctrlKey: keyboardState.modifiers.ctrl, metaKey: keyboardState.modifiers.meta, shiftKey: keyboardState.modifiers.shift, } - if (Event === FakePointerEvent || type === 'click') { + if (type === 'click' || type.startsWith('pointer')) { init.pointerId = pointerId init.pointerType = pointerType } @@ -61,9 +51,80 @@ export function firePointerEvent( .map(p => p.keyDef.button ?? 0), ) } - if (['mousedown', 'mouseup', 'click'].includes(type)) { + if (['mousedown', 'mouseup', 'click', 'dblclick'].includes(type)) { init.detail = clickCount } - return fireEvent(target, new Event(type, init)) + const eventKey = Object.keys(eventMap).find(k => k.toLowerCase() === type) + const event = createEvent[eventKey as keyof typeof createEvent](target, init) + + // see https://github.com/testing-library/react-testing-library/issues/268 + assignPositionInit(event as MouseEvent, init) + assignPointerInit(event as PointerEvent, init) + + return fireEvent(target, event) +} + +export interface PointerCoords { + x?: number + y?: number + clientX?: number + clientY?: number + offsetX?: number + offsetY?: number + pageX?: number + pageY?: number + screenX?: number + screenY?: number +} + +function assignProps( + obj: MouseEvent | PointerEvent, + props: MouseEventInit & PointerEventInit & PointerCoords, +) { + for (const [key, value] of Object.entries(props)) { + Object.defineProperty(obj, key, {get: () => value}) + } +} + +function assignPositionInit( + obj: MouseEvent | PointerEvent, + { + x, + y, + clientX, + clientY, + offsetX, + offsetY, + pageX, + pageY, + screenX, + screenY, + }: PointerCoords, +) { + assignProps(obj, { + /* istanbul ignore start */ + x: x ?? clientX ?? 0, + y: y ?? clientY ?? 0, + clientX: x ?? clientX ?? 0, + clientY: y ?? clientY ?? 0, + offsetX: offsetX ?? 0, + offsetY: offsetY ?? 0, + pageX: pageX ?? 0, + pageY: pageY ?? 0, + screenX: screenX ?? 0, + screenY: screenY ?? 0, + /* istanbul ignore end */ + }) +} + +function assignPointerInit( + obj: MouseEvent | PointerEvent, + {isPrimary, pointerId, pointerType}: PointerEventInit, +) { + assignProps(obj, { + isPrimary, + pointerId, + pointerType, + }) } diff --git a/tests/_helpers/utils.ts b/tests/_helpers/utils.ts index f70b212e..cdb5f23e 100644 --- a/tests/_helpers/utils.ts +++ b/tests/_helpers/utils.ts @@ -1,6 +1,6 @@ /* eslint-disable testing-library/no-node-access */ import {eventMap} from '@testing-library/dom/dist/event-map' -import {isElementType} from '#src/utils' +import {isElementType, MouseButton} from '#src/utils' // this is pretty helpful: // https://codesandbox.io/s/quizzical-worker-eo909 @@ -134,15 +134,22 @@ const eventLabelGetters = { .trim() }, MouseEvent(event: MouseEvent) { - // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button - const mouseButtonMap: Record = { - 0: 'Left', - 1: 'Middle', - 2: 'Right', - 3: 'Browser Back', - 4: 'Browser Forward', + if ( + [ + 'click', + 'dblclick', + 'mousedown', + 'mouseup', + 'pointerdown', + 'pointerup', + ].includes(event.type) + ) { + const buttonName = Object.keys(MouseButton).find( + k => MouseButton[k as keyof typeof MouseButton] === event.button, + ) + // const buttonName = Object.keys(MouseButton).find(k => MouseButton[k as keyof typeof MouseButton] === event.button) + return buttonName ?? `button${event.button}` } - return `${mouseButtonMap[event.button]} (${event.button})` }, } as const diff --git a/tests/clear.js b/tests/clear.js index 79d39c20..c5e6b062 100644 --- a/tests/clear.js +++ b/tests/clear.js @@ -15,13 +15,13 @@ test('clears text', () => { input[value="hello"] - pointermove input[value="hello"] - mousemove input[value="hello"] - pointerdown - input[value="hello"] - mousedown + input[value="hello"] - mousedown: primary input[value="hello"] - focus input[value="hello"] - focusin input[value="hello"] - select input[value="hello"] - pointerup - input[value="hello"] - mouseup - input[value="hello"] - click + input[value="hello"] - mouseup: primary + input[value="hello"] - click: primary input[value="hello"] - select input[value="hello"] - select input[value="hello"] - keydown: Delete (46) @@ -59,13 +59,13 @@ test('does not clear text on readonly inputs', () => { input[value="hello"] - pointermove input[value="hello"] - mousemove input[value="hello"] - pointerdown - input[value="hello"] - mousedown + input[value="hello"] - mousedown: primary input[value="hello"] - focus input[value="hello"] - focusin input[value="hello"] - select input[value="hello"] - pointerup - input[value="hello"] - mouseup - input[value="hello"] - click + input[value="hello"] - mouseup: primary + input[value="hello"] - click: primary input[value="hello"] - select input[value="hello"] - select input[value="hello"] - keydown: Delete (46) diff --git a/tests/click/click.js b/tests/click/click.js index 76b90358..071d746e 100644 --- a/tests/click/click.js +++ b/tests/click/click.js @@ -14,12 +14,12 @@ test('click in button', () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary `) }) @@ -49,12 +49,12 @@ test('clicking a checkbox', () => { input[checked=false] - pointermove input[checked=false] - mousemove input[checked=false] - pointerdown - input[checked=false] - mousedown + input[checked=false] - mousedown: primary input[checked=false] - focus input[checked=false] - focusin input[checked=false] - pointerup - input[checked=false] - mouseup - input[checked=true] - click + input[checked=false] - mouseup: primary + input[checked=true] - click: primary unchecked -> checked input[checked=true] - input input[checked=true] - change @@ -92,12 +92,12 @@ test('clicking a radio button', () => { input[checked=false] - pointermove input[checked=false] - mousemove input[checked=false] - pointerdown - input[checked=false] - mousedown + input[checked=false] - mousedown: primary input[checked=false] - focus input[checked=false] - focusin input[checked=false] - pointerup - input[checked=false] - mouseup - input[checked=true] - click + input[checked=false] - mouseup: primary + input[checked=true] - click: primary unchecked -> checked input[checked=true] - input input[checked=true] - change @@ -135,10 +135,10 @@ test('should fire the correct events for
', () => { div - pointermove div - mousemove div - pointerdown - div - mousedown + div - mousedown: primary div - pointerup - div - mouseup - div - click + div - mouseup: primary + div - click: primary `) }) @@ -182,12 +182,12 @@ test('should blur the previous element', () => { input[name="b"][value=""] - pointermove input[name="b"][value=""] - mousemove input[name="b"][value=""] - pointerdown - input[name="b"][value=""] - mousedown + input[name="b"][value=""] - mousedown: primary input[name="a"][value=""] - focusout input[name="b"][value=""] - focusin input[name="b"][value=""] - pointerup - input[name="b"][value=""] - mouseup - input[name="b"][value=""] - click + input[name="b"][value=""] - mouseup: primary + input[name="b"][value=""] - click: primary `) // focus/blur events don't bubble (but the focusout/focusin do!) // we just want to make sure the blur was fired on a @@ -220,10 +220,10 @@ test('should not blur the previous element when mousedown prevents default', () input[name="b"][value=""] - pointermove input[name="b"][value=""] - mousemove input[name="b"][value=""] - pointerdown - input[name="b"][value=""] - mousedown + input[name="b"][value=""] - mousedown: primary input[name="b"][value=""] - pointerup - input[name="b"][value=""] - mouseup - input[name="b"][value=""] - click + input[name="b"][value=""] - mouseup: primary + input[name="b"][value=""] - click: primary `) // focus/blur events don't bubble (but the focusout do!) // we just want to make sure the blur was fired on a @@ -290,10 +290,10 @@ test('fires no events when clicking a label with a nested control that is disabl label - pointermove label - mousemove label - pointerdown - label - mousedown + label - mousedown: primary label - pointerup - label - mouseup - label - click + label - mouseup: primary + label - click: primary `) }) diff --git a/tests/click/dblclick.js b/tests/click/dblclick.js index 7eae6ca1..720a6a93 100644 --- a/tests/click/dblclick.js +++ b/tests/click/dblclick.js @@ -14,18 +14,18 @@ test('fires the correct events on buttons', () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary button - pointerdown - button - mousedown + button - mousedown: primary button - pointerup - button - mouseup - button - click - button - dblclick + button - mouseup: primary + button - click: primary + button - dblclick: primary `) }) @@ -61,24 +61,24 @@ test('fires the correct events on checkboxes', () => { input[checked=false] - pointermove input[checked=false] - mousemove input[checked=false] - pointerdown - input[checked=false] - mousedown + input[checked=false] - mousedown: primary input[checked=false] - focus input[checked=false] - focusin input[checked=false] - pointerup - input[checked=false] - mouseup - input[checked=true] - click + input[checked=false] - mouseup: primary + input[checked=true] - click: primary unchecked -> checked input[checked=true] - input input[checked=true] - change input[checked=true] - pointerdown - input[checked=true] - mousedown + input[checked=true] - mousedown: primary input[checked=true] - pointerup - input[checked=true] - mouseup - input[checked=false] - click + input[checked=true] - mouseup: primary + input[checked=false] - click: primary checked -> unchecked input[checked=false] - input input[checked=false] - change - input[checked=false] - dblclick + input[checked=false] - dblclick: primary `) }) @@ -95,18 +95,18 @@ test('fires the correct events on regular inputs', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click - input[value=""] - dblclick + input[value=""] - mouseup: primary + input[value=""] - click: primary + input[value=""] - dblclick: primary `) }) @@ -123,16 +123,16 @@ test('fires the correct events on divs', () => { div - pointermove div - mousemove div - pointerdown - div - mousedown + div - mousedown: primary div - pointerup - div - mouseup - div - click + div - mouseup: primary + div - click: primary div - pointerdown - div - mousedown + div - mousedown: primary div - pointerup - div - mouseup - div - click - div - dblclick + div - mouseup: primary + div - click: primary + div - dblclick: primary `) }) @@ -224,7 +224,7 @@ test('fires mouse events with the correct properties', () => { pointerup - pointerId=1; pointerType=mouse; isPrimary=true mouseup - button=0; buttons=0; detail=2 click - button=0; buttons=0; detail=2 - dblclick + dblclick - button=0; buttons=0; detail=2 `) }) @@ -251,7 +251,7 @@ test('fires mouse events with custom button property', () => { pointerup - pointerId=1; pointerType=mouse; isPrimary=true mouseup - button=0; buttons=0; detail=2 click - button=0; buttons=0; detail=2 - dblclick + dblclick - button=0; buttons=0; detail=2 `) }) @@ -277,7 +277,7 @@ test('fires mouse events with custom buttons property', () => { pointerup - pointerId=1; pointerType=mouse; isPrimary=true mouseup - button=0; buttons=0; detail=2 click - button=0; buttons=0; detail=2 - dblclick + dblclick - button=0; buttons=0; detail=2 `) }) diff --git a/tests/click/tripleClick.ts b/tests/click/tripleClick.ts index 34fa7dcc..4f09f4ba 100644 --- a/tests/click/tripleClick.ts +++ b/tests/click/tripleClick.ts @@ -27,26 +27,26 @@ test('select input per triple click', () => { input[value="foo bar"] - pointermove input[value="foo bar"] - mousemove input[value="foo bar"] - pointerdown - input[value="foo bar"] - mousedown + input[value="foo bar"] - mousedown: primary input[value="foo bar"] - focus input[value="foo bar"] - focusin input[value="foo bar"] - select input[value="foo bar"] - pointerup - input[value="foo bar"] - mouseup - input[value="foo bar"] - click + input[value="foo bar"] - mouseup: primary + input[value="foo bar"] - click: primary input[value="foo bar"] - pointerdown - input[value="foo bar"] - mousedown + input[value="foo bar"] - mousedown: primary input[value="foo bar"] - select input[value="foo bar"] - pointerup - input[value="foo bar"] - mouseup - input[value="foo bar"] - click - input[value="foo bar"] - dblclick + input[value="foo bar"] - mouseup: primary + input[value="foo bar"] - click: primary + input[value="foo bar"] - dblclick: primary input[value="foo bar"] - pointerdown - input[value="foo bar"] - mousedown + input[value="foo bar"] - mousedown: primary input[value="foo bar"] - select input[value="foo bar"] - pointerup - input[value="foo bar"] - mouseup - input[value="foo bar"] - click + input[value="foo bar"] - mouseup: primary + input[value="foo bar"] - click: primary `) }) diff --git a/tests/keyboard/plugin/functional.ts b/tests/keyboard/plugin/functional.ts index 283df71a..95df6608 100644 --- a/tests/keyboard/plugin/functional.ts +++ b/tests/keyboard/plugin/functional.ts @@ -17,12 +17,12 @@ test('produce extra events for the Control key when AltGraph is pressed', () => input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Control (17) input[value=""] - keydown: AltGraph (0) input[value=""] - keyup: AltGraph (0) @@ -46,12 +46,12 @@ test('backspace to valid value', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 5 (53) input[value=""] - keypress: 5 (53) input[value="5"] - input @@ -93,7 +93,7 @@ test('trigger click event on [Enter] keydown on HTMLAnchorElement', () => { a - focusin a - keydown: Enter (13) a - keypress: Enter (13) - a - click: Left (0) + a - click: primary a - keyup: Enter (13) `) }) @@ -113,7 +113,7 @@ test('trigger click event on [Enter] keypress on HTMLButtonElement', () => { button - focusin button - keydown: Enter (13) button - keypress: Enter (13) - button - click: Left (0) + button - click: primary button - keyup: Enter (13) `) }) @@ -164,7 +164,7 @@ test('trigger click event on [Space] keyup on HTMLButtonElement', () => { button - keydown: (32) button - keypress: (32) button - keyup: (32) - button - click: Left (0) + button - click: primary `) }) @@ -186,7 +186,7 @@ test('trigger click event on [Space] keyup on HTMLInputElement type=button', () input[value=""] - keydown: (32) input[value=""] - keypress: (32) input[value=""] - keyup: (32) - input[value=""] - click: Left (0) + input[value=""] - click: primary `) }) @@ -205,7 +205,7 @@ test('trigger change event on [Space] keyup on HTMLInputElement type=radio', () input[checked=false] - keydown: (32) input[checked=false] - keypress: (32) input[checked=false] - keyup: (32) - input[checked=true] - click: Left (0) + input[checked=true] - click: primary unchecked -> checked input[checked=true] - input input[checked=true] - change diff --git a/tests/pointer/index.ts b/tests/pointer/index.ts index 0b56b875..41aeefe9 100644 --- a/tests/pointer/index.ts +++ b/tests/pointer/index.ts @@ -18,7 +18,7 @@ test('double click', () => { pointerup - pointerId=1; pointerType=mouse; isPrimary=true mouseup - button=0; buttons=0; detail=2 click - button=0; buttons=0; detail=2 - dblclick + dblclick - button=0; buttons=0; detail=2 `) }) @@ -172,7 +172,7 @@ test('other keys reset click counter, but keyup/click still uses the old count', pointerup - pointerId=1; pointerType=mouse; isPrimary=true mouseup - button=0; buttons=0; detail=2 click - button=0; buttons=0; detail=2 - dblclick + dblclick - button=0; buttons=0; detail=2 pointerdown - pointerId=1; pointerType=mouse; isPrimary=true mousedown - button=0; buttons=1; detail=1 pointerup - pointerId=1; pointerType=mouse; isPrimary=true @@ -230,7 +230,7 @@ test('double click per touch device', () => { mousedown - button=0; buttons=0; detail=2 mouseup - button=0; buttons=0; detail=2 click - button=0; buttons=0; detail=2 - dblclick + dblclick - button=0; buttons=0; detail=2 `) }) @@ -314,9 +314,9 @@ test('move touch over elements', () => { div - mouseover div - mouseenter div - mousemove - div - mousedown - div - mouseup - div - click + div - mousedown: primary + div - mouseup: primary + div - click: primary `) }) diff --git a/tests/react/type.tsx b/tests/react/type.tsx index 26d78431..1e1db805 100644 --- a/tests/react/type.tsx +++ b/tests/react/type.tsx @@ -50,31 +50,31 @@ describe('typing in a controlled input', () => { expect(element).toHaveValue('$23') expect(getEventSnapshot()).toMatchInlineSnapshot(` - Events fired on: input[value="$23"] - - input[value=""] - pointerover - input[value=""] - pointerenter - input[value=""] - mouseover - input[value=""] - mouseenter - input[value=""] - pointermove - input[value=""] - mousemove - input[value=""] - pointerdown - input[value=""] - mousedown - input[value=""] - focus - input[value=""] - focusin - input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click - input[value=""] - keydown: 2 (50) - input[value=""] - keypress: 2 (50) - input[value="2"] - input - "2{CURSOR}" -> "$2{CURSOR}" - input[value="$2"] - keyup: 2 (50) - input[value="$2"] - keydown: 3 (51) - input[value="$2"] - keypress: 3 (51) - input[value="$23"] - input - input[value="$23"] - keyup: 3 (51) - `) + Events fired on: input[value="$23"] + + input[value=""] - pointerover + input[value=""] - pointerenter + input[value=""] - mouseover + input[value=""] - mouseenter + input[value=""] - pointermove + input[value=""] - mousemove + input[value=""] - pointerdown + input[value=""] - mousedown: primary + input[value=""] - focus + input[value=""] - focusin + input[value=""] - pointerup + input[value=""] - mouseup: primary + input[value=""] - click: primary + input[value=""] - keydown: 2 (50) + input[value=""] - keypress: 2 (50) + input[value="2"] - input + "2{CURSOR}" -> "$2{CURSOR}" + input[value="$2"] - keyup: 2 (50) + input[value="$2"] - keydown: 3 (51) + input[value="$2"] - keypress: 3 (51) + input[value="$23"] - input + input[value="$23"] - keyup: 3 (51) + `) }) test('typing in the middle of a controlled input', () => { @@ -96,12 +96,12 @@ describe('typing in a controlled input', () => { input[value="$23"] - pointermove input[value="$23"] - mousemove input[value="$23"] - pointerdown - input[value="$23"] - mousedown + input[value="$23"] - mousedown: primary input[value="$23"] - focus input[value="$23"] - focusin input[value="$23"] - pointerup - input[value="$23"] - mouseup - input[value="$23"] - click + input[value="$23"] - mouseup: primary + input[value="$23"] - click: primary input[value="$23"] - select input[value="$23"] - keydown: 1 (49) input[value="$23"] - keypress: 1 (49) @@ -142,12 +142,12 @@ describe('typing in a controlled input', () => { input[value="$23"] - pointermove input[value="$23"] - mousemove input[value="$23"] - pointerdown - input[value="$23"] - mousedown + input[value="$23"] - mousedown: primary input[value="$23"] - focus input[value="$23"] - focusin input[value="$23"] - pointerup - input[value="$23"] - mouseup - input[value="$23"] - click + input[value="$23"] - mouseup: primary + input[value="$23"] - click: primary input[value="$23"] - select input[value="$23"] - keydown: Backspace (8) input[value="23"] - select @@ -161,10 +161,10 @@ describe('typing in a controlled input', () => { input[value="$23"] - pointermove input[value="$23"] - mousemove input[value="$23"] - pointerdown - input[value="$23"] - mousedown + input[value="$23"] - mousedown: primary input[value="$23"] - pointerup - input[value="$23"] - mouseup - input[value="$23"] - click + input[value="$23"] - mouseup: primary + input[value="$23"] - click: primary input[value="$23"] - keydown: 4 (52) input[value="$23"] - keypress: 4 (52) input[value="$234"] - input diff --git a/tests/selectOptions/deselect.js b/tests/selectOptions/deselect.js index c8f40c3b..df3d200a 100644 --- a/tests/selectOptions/deselect.js +++ b/tests/selectOptions/deselect.js @@ -14,19 +14,19 @@ test('fires correct events', () => { option[value="1"][selected=true] - pointerover select[name="select"][value=["1"]] - pointerenter - option[value="1"][selected=true] - mouseover: Left (0) - select[name="select"][value=["1"]] - mouseenter: Left (0) + option[value="1"][selected=true] - mouseover + select[name="select"][value=["1"]] - mouseenter option[value="1"][selected=true] - pointermove - option[value="1"][selected=true] - mousemove: Left (0) + option[value="1"][selected=true] - mousemove option[value="1"][selected=true] - pointerdown - option[value="1"][selected=true] - mousedown: Left (0) + option[value="1"][selected=true] - mousedown: primary select[name="select"][value=["1"]] - focus select[name="select"][value=["1"]] - focusin option[value="1"][selected=true] - pointerup - option[value="1"][selected=true] - mouseup: Left (0) + option[value="1"][selected=true] - mouseup: primary select[name="select"][value=[]] - input select[name="select"][value=[]] - change - option[value="1"][selected=false] - click: Left (0) + option[value="1"][selected=false] - click: primary `) expect(form).toHaveFormValues({select: []}) @@ -47,18 +47,18 @@ test('blurs previously focused element', () => { Events fired on: form option[value="1"][selected=false] - pointerover - option[value="1"][selected=false] - mouseover: Left (0) + option[value="1"][selected=false] - mouseover option[value="1"][selected=false] - pointermove - option[value="1"][selected=false] - mousemove: Left (0) + option[value="1"][selected=false] - mousemove option[value="1"][selected=false] - pointerdown - option[value="1"][selected=false] - mousedown: Left (0) + option[value="1"][selected=false] - mousedown: primary button - focusout select[name="select"][value=[]] - focusin option[value="1"][selected=false] - pointerup - option[value="1"][selected=false] - mouseup: Left (0) + option[value="1"][selected=false] - mouseup: primary select[name="select"][value=[]] - input select[name="select"][value=[]] - change - option[value="1"][selected=false] - click: Left (0) + option[value="1"][selected=false] - click: primary `) }) diff --git a/tests/selectOptions/select.js b/tests/selectOptions/select.js index a5834788..8912f8bc 100644 --- a/tests/selectOptions/select.js +++ b/tests/selectOptions/select.js @@ -19,21 +19,21 @@ test('fires correct events', () => { select[name="select"][value="1"] - pointermove select[name="select"][value="1"] - mousemove select[name="select"][value="1"] - pointerdown - select[name="select"][value="1"] - mousedown + select[name="select"][value="1"] - mousedown: primary select[name="select"][value="1"] - focus select[name="select"][value="1"] - focusin select[name="select"][value="1"] - pointerup - select[name="select"][value="1"] - mouseup - select[name="select"][value="1"] - click + select[name="select"][value="1"] - mouseup: primary + select[name="select"][value="1"] - click: primary select[name="select"][value="2"] - input select[name="select"][value="2"] - change select[name="select"][value="2"] - pointerover select[name="select"][value="2"] - pointerenter - select[name="select"][value="2"] - mouseover: Left (0) - select[name="select"][value="2"] - mouseenter: Left (0) + select[name="select"][value="2"] - mouseover + select[name="select"][value="2"] - mouseenter select[name="select"][value="2"] - pointerup - select[name="select"][value="2"] - mouseup: Left (0) - select[name="select"][value="2"] - click: Left (0) + select[name="select"][value="2"] - mouseup: primary + select[name="select"][value="2"] - click: primary `) const [o1, o2, o3] = options expect(o1.selected).toBe(false) @@ -56,10 +56,10 @@ test('fires correct events on listBox select', () => { li#2[value="2"][aria-selected=false] - pointermove li#2[value="2"][aria-selected=false] - mousemove li#2[value="2"][aria-selected=false] - pointerdown - li#2[value="2"][aria-selected=false] - mousedown + li#2[value="2"][aria-selected=false] - mousedown: primary li#2[value="2"][aria-selected=false] - pointerup - li#2[value="2"][aria-selected=false] - mouseup - li#2[value="2"][aria-selected=true] - click + li#2[value="2"][aria-selected=false] - mouseup: primary + li#2[value="2"][aria-selected=true] - click: primary li#2[value="2"][aria-selected=true] - pointermove li#2[value="2"][aria-selected=true] - mousemove li#2[value="2"][aria-selected=true] - pointerout @@ -79,32 +79,32 @@ test('fires correct events on multi-selects', () => { option[value="1"][selected=false] - pointerover select[name="select"][value=[]] - pointerenter - option[value="1"][selected=false] - mouseover: Left (0) - select[name="select"][value=[]] - mouseenter: Left (0) + option[value="1"][selected=false] - mouseover + select[name="select"][value=[]] - mouseenter option[value="1"][selected=false] - pointermove - option[value="1"][selected=false] - mousemove: Left (0) + option[value="1"][selected=false] - mousemove option[value="1"][selected=false] - pointerdown - option[value="1"][selected=false] - mousedown: Left (0) + option[value="1"][selected=false] - mousedown: primary select[name="select"][value=[]] - focus select[name="select"][value=[]] - focusin option[value="1"][selected=false] - pointerup - option[value="1"][selected=false] - mouseup: Left (0) + option[value="1"][selected=false] - mouseup: primary select[name="select"][value=["1"]] - input select[name="select"][value=["1"]] - change - option[value="1"][selected=true] - click: Left (0) + option[value="1"][selected=true] - click: primary option[value="3"][selected=false] - pointerover select[name="select"][value=["1"]] - pointerenter - option[value="3"][selected=false] - mouseover: Left (0) - select[name="select"][value=["1"]] - mouseenter: Left (0) + option[value="3"][selected=false] - mouseover + select[name="select"][value=["1"]] - mouseenter option[value="3"][selected=false] - pointermove - option[value="3"][selected=false] - mousemove: Left (0) + option[value="3"][selected=false] - mousemove option[value="3"][selected=false] - pointerdown - option[value="3"][selected=false] - mousedown: Left (0) + option[value="3"][selected=false] - mousedown: primary option[value="3"][selected=false] - pointerup - option[value="3"][selected=false] - mouseup: Left (0) + option[value="3"][selected=false] - mouseup: primary select[name="select"][value=["1","3"]] - input select[name="select"][value=["1","3"]] - change - option[value="3"][selected=true] - click: Left (0) + option[value="3"][selected=true] - click: primary `) const [o1, o2, o3] = options expect(o1.selected).toBe(true) @@ -276,21 +276,21 @@ test('fires correct events when pointer events set to none but skipPointerEvents select[name="select"][value="1"] - pointermove select[name="select"][value="1"] - mousemove select[name="select"][value="1"] - pointerdown - select[name="select"][value="1"] - mousedown + select[name="select"][value="1"] - mousedown: primary select[name="select"][value="1"] - focus select[name="select"][value="1"] - focusin select[name="select"][value="1"] - pointerup - select[name="select"][value="1"] - mouseup - select[name="select"][value="1"] - click + select[name="select"][value="1"] - mouseup: primary + select[name="select"][value="1"] - click: primary select[name="select"][value="2"] - input select[name="select"][value="2"] - change select[name="select"][value="2"] - pointerover select[name="select"][value="2"] - pointerenter - select[name="select"][value="2"] - mouseover: Left (0) - select[name="select"][value="2"] - mouseenter: Left (0) + select[name="select"][value="2"] - mouseover + select[name="select"][value="2"] - mouseenter select[name="select"][value="2"] - pointerup - select[name="select"][value="2"] - mouseup: Left (0) - select[name="select"][value="2"] - click: Left (0) + select[name="select"][value="2"] - mouseup: primary + select[name="select"][value="2"] - click: primary `) const [o1, o2, o3] = options expect(o1.selected).toBe(false) @@ -311,32 +311,32 @@ test('fires correct events on multi-selects when pointer events is set and skipP option[value="1"][selected=false] - pointerover select[name="select"][value=[]] - pointerenter - option[value="1"][selected=false] - mouseover: Left (0) - select[name="select"][value=[]] - mouseenter: Left (0) + option[value="1"][selected=false] - mouseover + select[name="select"][value=[]] - mouseenter option[value="1"][selected=false] - pointermove - option[value="1"][selected=false] - mousemove: Left (0) + option[value="1"][selected=false] - mousemove option[value="1"][selected=false] - pointerdown - option[value="1"][selected=false] - mousedown: Left (0) + option[value="1"][selected=false] - mousedown: primary select[name="select"][value=[]] - focus select[name="select"][value=[]] - focusin option[value="1"][selected=false] - pointerup - option[value="1"][selected=false] - mouseup: Left (0) + option[value="1"][selected=false] - mouseup: primary select[name="select"][value=["1"]] - input select[name="select"][value=["1"]] - change - option[value="1"][selected=true] - click: Left (0) + option[value="1"][selected=true] - click: primary option[value="3"][selected=false] - pointerover select[name="select"][value=["1"]] - pointerenter - option[value="3"][selected=false] - mouseover: Left (0) - select[name="select"][value=["1"]] - mouseenter: Left (0) + option[value="3"][selected=false] - mouseover + select[name="select"][value=["1"]] - mouseenter option[value="3"][selected=false] - pointermove - option[value="3"][selected=false] - mousemove: Left (0) + option[value="3"][selected=false] - mousemove option[value="3"][selected=false] - pointerdown - option[value="3"][selected=false] - mousedown: Left (0) + option[value="3"][selected=false] - mousedown: primary option[value="3"][selected=false] - pointerup - option[value="3"][selected=false] - mouseup: Left (0) + option[value="3"][selected=false] - mouseup: primary select[name="select"][value=["1","3"]] - input select[name="select"][value=["1","3"]] - change - option[value="3"][selected=true] - click: Left (0) + option[value="3"][selected=true] - click: primary `) const [o1, o2, o3] = options expect(o1.selected).toBe(true) diff --git a/tests/type/index.js b/tests/type/index.js index 96cd2acb..bcf4d72f 100644 --- a/tests/type/index.js +++ b/tests/type/index.js @@ -16,12 +16,12 @@ test('types text in input', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: S (83) input[value=""] - keypress: S (83) input[value="S"] - input @@ -77,12 +77,12 @@ test('types text inside custom element', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: S (83) input[value=""] - keypress: S (83) input[value="S"] - input @@ -111,12 +111,12 @@ test('types text in textarea', () => { textarea[value=""] - pointermove textarea[value=""] - mousemove textarea[value=""] - pointerdown - textarea[value=""] - mousedown + textarea[value=""] - mousedown: primary textarea[value=""] - focus textarea[value=""] - focusin textarea[value=""] - pointerup - textarea[value=""] - mouseup - textarea[value=""] - click + textarea[value=""] - mouseup: primary + textarea[value=""] - click: primary textarea[value=""] - keydown: S (83) textarea[value=""] - keypress: S (83) textarea[value="S"] - input @@ -148,12 +148,12 @@ test('does not fire input event when keypress calls prevent default', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: a (97) input[value=""] - keypress: a (97) input[value=""] - keyup: a (97) @@ -176,12 +176,12 @@ test('does not fire keypress or input events when keydown calls prevent default' input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: a (97) input[value=""] - keyup: a (97) `) @@ -210,12 +210,12 @@ test('does not fire input when readonly', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: a (97) input[value=""] - keypress: a (97) input[value=""] - keyup: a (97) @@ -308,13 +308,13 @@ test('typing in a textarea with existing text', () => { textarea[value="Hello, "] - pointermove textarea[value="Hello, "] - mousemove textarea[value="Hello, "] - pointerdown - textarea[value="Hello, "] - mousedown + textarea[value="Hello, "] - mousedown: primary textarea[value="Hello, "] - focus textarea[value="Hello, "] - focusin textarea[value="Hello, "] - select textarea[value="Hello, "] - pointerup - textarea[value="Hello, "] - mouseup - textarea[value="Hello, "] - click + textarea[value="Hello, "] - mouseup: primary + textarea[value="Hello, "] - click: primary textarea[value="Hello, "] - keydown: 1 (49) textarea[value="Hello, "] - keypress: 1 (49) textarea[value="Hello, 1"] - input @@ -347,13 +347,13 @@ test('accepts an initialSelectionStart and initialSelectionEnd', () => { textarea[value="Hello, "] - pointermove textarea[value="Hello, "] - mousemove textarea[value="Hello, "] - pointerdown - textarea[value="Hello, "] - mousedown + textarea[value="Hello, "] - mousedown: primary textarea[value="Hello, "] - focus textarea[value="Hello, "] - focusin textarea[value="Hello, "] - select textarea[value="Hello, "] - pointerup - textarea[value="Hello, "] - mouseup - textarea[value="Hello, "] - click + textarea[value="Hello, "] - mouseup: primary + textarea[value="Hello, "] - click: primary textarea[value="Hello, "] - select textarea[value="Hello, "] - keydown: 1 (49) textarea[value="Hello, "] - keypress: 1 (49) @@ -392,12 +392,12 @@ test('can type into an input with type `date`', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 2 (50) input[value=""] - keypress: 2 (50) input[value=""] - keyup: 2 (50) @@ -453,12 +453,12 @@ test('can type "-" into number inputs', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: - (45) input[value=""] - keypress: - (45) input[value=""] - input @@ -486,12 +486,12 @@ test('can type "." into number inputs', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 3 (51) input[value=""] - keypress: 3 (51) input[value="3"] - input @@ -712,12 +712,12 @@ test('should type inside a contenteditable div', () => { div - pointermove div - mousemove div - pointerdown - div - mousedown + div - mousedown: primary div - focus div - focusin div - pointerup - div - mouseup - div - click + div - mouseup: primary + div - click: primary div - keydown: b (98) div - keypress: b (98) div - input @@ -749,10 +749,10 @@ test('should not type inside a contenteditable=false div', () => { div - pointermove div - mousemove div - pointerdown - div - mousedown + div - mousedown: primary div - pointerup - div - mouseup - div - click + div - mouseup: primary + div - click: primary `) }) @@ -769,12 +769,12 @@ test('navigation key: {arrowleft} and {arrowright} moves the cursor for ' input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: b (98) input[value=""] - keypress: b (98) input[value="b"] - input @@ -810,12 +810,12 @@ test('navigation key: {arrowleft} and {arrowright} moves the cursor for { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: c (99) input[value=""] - keypress: c (99) input[value="c"] - input @@ -897,12 +897,12 @@ test('navigation key: {pageUp} and {pageDown} moves the cursor for ', () input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: c (99) input[value=""] - keypress: c (99) input[value="c"] - input @@ -943,12 +943,12 @@ test('can type into an input with type `time`', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 0 (48) input[value=""] - keypress: 0 (48) input[value=""] - keyup: 0 (48) @@ -985,12 +985,12 @@ test('can type into an input with type `time` without ":"', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 0 (48) input[value=""] - keypress: 0 (48) input[value=""] - keyup: 0 (48) @@ -1025,12 +1025,12 @@ test('can type more a number higher than 60 minutes into an input `time` and the input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 2 (50) input[value=""] - keypress: 2 (50) input[value=""] - keyup: 2 (50) @@ -1069,12 +1069,12 @@ test('can type letters into an input `time` and they are ignored', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 1 (49) input[value=""] - keypress: 1 (49) input[value=""] - keyup: 1 (49) @@ -1128,12 +1128,12 @@ test('can type a digit bigger in the hours section, bigger than 2 and it shows t input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 9 (57) input[value=""] - keypress: 9 (57) input[value=""] - keyup: 9 (57) @@ -1169,12 +1169,12 @@ test('can type two digits in the hours section, equals to 24 and it shows the ho input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 2 (50) input[value=""] - keypress: 2 (50) input[value=""] - keyup: 2 (50) @@ -1213,12 +1213,12 @@ test('can type two digits in the hours section, bigger than 24 and less than 30, input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 2 (50) input[value=""] - keypress: 2 (50) input[value=""] - keyup: 2 (50) @@ -1258,12 +1258,12 @@ test('{arrowdown} fires keyup/keydown events', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: ArrowDown (40) input[value=""] - keyup: ArrowDown (40) `) @@ -1284,12 +1284,12 @@ test('{arrowup} fires keyup/keydown events', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: ArrowUp (38) input[value=""] - keyup: ArrowUp (38) `) @@ -1309,7 +1309,7 @@ test('{enter} fires click on links', () => { a - focusin a - keydown: Enter (13) a - keypress: Enter (13) - a - click: Left (0) + a - click: primary a - keyup: Enter (13) `) }) diff --git a/tests/type/modifiers.js b/tests/type/modifiers.js index c8b76adf..58a1c6c2 100644 --- a/tests/type/modifiers.js +++ b/tests/type/modifiers.js @@ -30,12 +30,12 @@ test('{esc} triggers typing the escape character', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Escape (27) input[value=""] - keyup: Escape (27) `) @@ -54,12 +54,12 @@ test('a{backspace}', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: a (97) input[value=""] - keypress: a (97) input[value="a"] - input @@ -83,12 +83,12 @@ test('{backspace}a', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Backspace (8) input[value=""] - keyup: Backspace (8) input[value=""] - keydown: a (97) @@ -115,13 +115,13 @@ test('{backspace} triggers typing the backspace character and deletes the charac input[value="yo"] - pointermove input[value="yo"] - mousemove input[value="yo"] - pointerdown - input[value="yo"] - mousedown + input[value="yo"] - mousedown: primary input[value="yo"] - focus input[value="yo"] - focusin input[value="yo"] - select input[value="yo"] - pointerup - input[value="yo"] - mouseup - input[value="yo"] - click + input[value="yo"] - mouseup: primary + input[value="yo"] - click: primary input[value="yo"] - select input[value="yo"] - keydown: Backspace (8) input[value="o"] - select @@ -147,13 +147,13 @@ test('{backspace} on a readOnly input', () => { input[value="yo"] - pointermove input[value="yo"] - mousemove input[value="yo"] - pointerdown - input[value="yo"] - mousedown + input[value="yo"] - mousedown: primary input[value="yo"] - focus input[value="yo"] - focusin input[value="yo"] - select input[value="yo"] - pointerup - input[value="yo"] - mouseup - input[value="yo"] - click + input[value="yo"] - mouseup: primary + input[value="yo"] - click: primary input[value="yo"] - keydown: Backspace (8) input[value="yo"] - keyup: Backspace (8) `) @@ -178,13 +178,13 @@ test('{backspace} does not fire input if keydown prevents default', () => { input[value="yo"] - pointermove input[value="yo"] - mousemove input[value="yo"] - pointerdown - input[value="yo"] - mousedown + input[value="yo"] - mousedown: primary input[value="yo"] - focus input[value="yo"] - focusin input[value="yo"] - select input[value="yo"] - pointerup - input[value="yo"] - mouseup - input[value="yo"] - click + input[value="yo"] - mouseup: primary + input[value="yo"] - click: primary input[value="yo"] - keydown: Backspace (8) input[value="yo"] - keyup: Backspace (8) `) @@ -208,13 +208,13 @@ test('{backspace} deletes the selected range', () => { input[value="Hi there"] - pointermove input[value="Hi there"] - mousemove input[value="Hi there"] - pointerdown - input[value="Hi there"] - mousedown + input[value="Hi there"] - mousedown: primary input[value="Hi there"] - focus input[value="Hi there"] - focusin input[value="Hi there"] - select input[value="Hi there"] - pointerup - input[value="Hi there"] - mouseup - input[value="Hi there"] - click + input[value="Hi there"] - mouseup: primary + input[value="Hi there"] - click: primary input[value="Hi there"] - select input[value="Hi there"] - keydown: Backspace (8) input[value="Here"] - select @@ -246,12 +246,12 @@ test('{alt}a{/alt}', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Alt (18) {alt} input[value=""] - keydown: a (97) {alt} input[value=""] - keyup: a (97) {alt} @@ -274,12 +274,12 @@ test('{meta}a{/meta}', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Meta (93) {meta} input[value=""] - keydown: a (97) {meta} input[value=""] - keypress: a (97) {meta} @@ -304,12 +304,12 @@ test('{ctrl}a{/ctrl}', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Control (17) {ctrl} input[value=""] - keydown: a (97) {ctrl} input[value=""] - keyup: a (97) {ctrl} @@ -332,12 +332,12 @@ test('{shift}a{/shift}', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Shift (16) {shift} input[value=""] - keydown: a (97) {shift} input[value=""] - keypress: a (97) {shift} @@ -363,12 +363,12 @@ test('{capslock}a{capslock}', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: CapsLock (20) input[value=""] - keyup: CapsLock (20) input[value=""] - keydown: a (97) @@ -395,12 +395,12 @@ test('a{enter}', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: a (97) input[value=""] - keypress: a (97) input[value="a"] - input @@ -430,12 +430,12 @@ test('{enter} with preventDefault keydown', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Enter (13) input[value=""] - keyup: Enter (13) `) @@ -456,15 +456,15 @@ test('{enter} on a button', () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary button - keydown: Enter (13) button - keypress: Enter (13) - button - click: Left (0) + button - click: primary button - keyup: Enter (13) `) }) @@ -488,12 +488,12 @@ test('{enter} on a button when keydown calls prevent default', () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary button - keydown: Enter (13) button - keyup: Enter (13) `) @@ -518,12 +518,12 @@ test('{enter} on a button when keypress calls prevent default', () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary button - keydown: Enter (13) button - keypress: Enter (13) button - keyup: Enter (13) @@ -545,16 +545,16 @@ test('{space} on a button', () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary button - keydown: (32) button - keypress: (32) button - keyup: (32) - button - click: Left (0) + button - click: primary `) }) @@ -573,16 +573,16 @@ test(`' ' on a button is the same as '{space}'`, () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary button - keydown: (32) button - keypress: (32) button - keyup: (32) - button - click: Left (0) + button - click: primary `) }) @@ -605,12 +605,12 @@ test('{space} with preventDefault keydown on button', () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary button - keydown: (32) button - keyup: (32) `) @@ -635,12 +635,12 @@ test('{space} with preventDefault keyup on button', () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary button - keydown: (32) button - keypress: (32) button - keyup: (32) @@ -662,12 +662,12 @@ test('{space} on an input', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: (32) input[value=""] - keypress: (32) input[value=" "] - input @@ -692,15 +692,15 @@ test('{enter} on an input type="color" fires same events as a button', () => { input[value="#ffffff"] - pointermove input[value="#ffffff"] - mousemove input[value="#ffffff"] - pointerdown - input[value="#ffffff"] - mousedown + input[value="#ffffff"] - mousedown: primary input[value="#ffffff"] - focus input[value="#ffffff"] - focusin input[value="#ffffff"] - pointerup - input[value="#ffffff"] - mouseup - input[value="#ffffff"] - click + input[value="#ffffff"] - mouseup: primary + input[value="#ffffff"] - click: primary input[value="#ffffff"] - keydown: Enter (13) input[value="#ffffff"] - keypress: Enter (13) - input[value="#ffffff"] - click: Left (0) + input[value="#ffffff"] - click: primary input[value="#ffffff"] - keyup: Enter (13) `) }) @@ -722,16 +722,16 @@ test('{space} on an input type="color" fires same events as a button', () => { input[value="#ffffff"] - pointermove input[value="#ffffff"] - mousemove input[value="#ffffff"] - pointerdown - input[value="#ffffff"] - mousedown + input[value="#ffffff"] - mousedown: primary input[value="#ffffff"] - focus input[value="#ffffff"] - focusin input[value="#ffffff"] - pointerup - input[value="#ffffff"] - mouseup - input[value="#ffffff"] - click + input[value="#ffffff"] - mouseup: primary + input[value="#ffffff"] - click: primary input[value="#ffffff"] - keydown: (32) input[value="#ffffff"] - keypress: (32) input[value="#ffffff"] - keyup: (32) - input[value="#ffffff"] - click: Left (0) + input[value="#ffffff"] - click: primary `) }) @@ -752,16 +752,16 @@ test(`' ' on input type="color" is the same as '{space}'`, () => { input[value="#ffffff"] - pointermove input[value="#ffffff"] - mousemove input[value="#ffffff"] - pointerdown - input[value="#ffffff"] - mousedown + input[value="#ffffff"] - mousedown: primary input[value="#ffffff"] - focus input[value="#ffffff"] - focusin input[value="#ffffff"] - pointerup - input[value="#ffffff"] - mouseup - input[value="#ffffff"] - click + input[value="#ffffff"] - mouseup: primary + input[value="#ffffff"] - click: primary input[value="#ffffff"] - keydown: (32) input[value="#ffffff"] - keypress: (32) input[value="#ffffff"] - keyup: (32) - input[value="#ffffff"] - click: Left (0) + input[value="#ffffff"] - click: primary `) }) @@ -780,12 +780,12 @@ test('{enter} on a textarea', () => { textarea[value=""] - pointermove textarea[value=""] - mousemove textarea[value=""] - pointerdown - textarea[value=""] - mousedown + textarea[value=""] - mousedown: primary textarea[value=""] - focus textarea[value=""] - focusin textarea[value=""] - pointerup - textarea[value=""] - mouseup - textarea[value=""] - click + textarea[value=""] - mouseup: primary + textarea[value=""] - click: primary textarea[value=""] - keydown: Enter (13) textarea[value=""] - keypress: Enter (13) textarea[value="\\n"] - input @@ -810,12 +810,12 @@ test('{enter} on a textarea when keydown calls prevent default', () => { textarea[value=""] - pointermove textarea[value=""] - mousemove textarea[value=""] - pointerdown - textarea[value=""] - mousedown + textarea[value=""] - mousedown: primary textarea[value=""] - focus textarea[value=""] - focusin textarea[value=""] - pointerup - textarea[value=""] - mouseup - textarea[value=""] - click + textarea[value=""] - mouseup: primary + textarea[value=""] - click: primary textarea[value=""] - keydown: Enter (13) textarea[value=""] - keyup: Enter (13) `) @@ -838,12 +838,12 @@ test('{enter} on a textarea when keypress calls prevent default', () => { textarea[value=""] - pointermove textarea[value=""] - mousemove textarea[value=""] - pointerdown - textarea[value=""] - mousedown + textarea[value=""] - mousedown: primary textarea[value=""] - focus textarea[value=""] - focusin textarea[value=""] - pointerup - textarea[value=""] - mouseup - textarea[value=""] - click + textarea[value=""] - mouseup: primary + textarea[value=""] - click: primary textarea[value=""] - keydown: Enter (13) textarea[value=""] - keypress: Enter (13) textarea[value=""] - keyup: Enter (13) @@ -865,16 +865,16 @@ test('{meta}{enter}{/meta} on a button', () => { button - pointermove button - mousemove button - pointerdown - button - mousedown + button - mousedown: primary button - focus button - focusin button - pointerup - button - mouseup - button - click + button - mouseup: primary + button - click: primary button - keydown: Meta (93) {meta} button - keydown: Enter (13) {meta} button - keypress: Enter (13) {meta} - button - click: Left (0) {meta} + button - click: primary {meta} button - keyup: Enter (13) {meta} button - keyup: Meta (93) `) @@ -895,12 +895,12 @@ test('{meta}{alt}{ctrl}a{/ctrl}{/alt}{/meta}', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Meta (93) {meta} input[value=""] - keydown: Alt (18) {alt}{meta} input[value=""] - keydown: Control (17) {alt}{meta}{ctrl} @@ -935,13 +935,13 @@ test('{selectall} selects all the text', () => { input[value="abcdefg"] - pointermove input[value="abcdefg"] - mousemove input[value="abcdefg"] - pointerdown - input[value="abcdefg"] - mousedown + input[value="abcdefg"] - mousedown: primary input[value="abcdefg"] - focus input[value="abcdefg"] - focusin input[value="abcdefg"] - select input[value="abcdefg"] - pointerup - input[value="abcdefg"] - mouseup - input[value="abcdefg"] - click + input[value="abcdefg"] - mouseup: primary + input[value="abcdefg"] - click: primary input[value="abcdefg"] - select `) }) @@ -966,13 +966,13 @@ test('{del} at the start of the input', () => { input[value="hello"] - pointermove input[value="hello"] - mousemove input[value="hello"] - pointerdown - input[value="hello"] - mousedown + input[value="hello"] - mousedown: primary input[value="hello"] - focus input[value="hello"] - focusin input[value="hello"] - select input[value="hello"] - pointerup - input[value="hello"] - mouseup - input[value="hello"] - click + input[value="hello"] - mouseup: primary + input[value="hello"] - click: primary input[value="hello"] - select input[value="hello"] - keydown: Delete (46) input[value="ello"] - select @@ -998,13 +998,13 @@ test('{del} at end of the input', () => { input[value="hello"] - pointermove input[value="hello"] - mousemove input[value="hello"] - pointerdown - input[value="hello"] - mousedown + input[value="hello"] - mousedown: primary input[value="hello"] - focus input[value="hello"] - focusin input[value="hello"] - select input[value="hello"] - pointerup - input[value="hello"] - mouseup - input[value="hello"] - click + input[value="hello"] - mouseup: primary + input[value="hello"] - click: primary input[value="hello"] - keydown: Delete (46) input[value="hello"] - keyup: Delete (46) `) @@ -1030,13 +1030,13 @@ test('{del} in the middle of the input', () => { input[value="hello"] - pointermove input[value="hello"] - mousemove input[value="hello"] - pointerdown - input[value="hello"] - mousedown + input[value="hello"] - mousedown: primary input[value="hello"] - focus input[value="hello"] - focusin input[value="hello"] - select input[value="hello"] - pointerup - input[value="hello"] - mouseup - input[value="hello"] - click + input[value="hello"] - mouseup: primary + input[value="hello"] - click: primary input[value="hello"] - select input[value="hello"] - keydown: Delete (46) input[value="helo"] - select @@ -1065,13 +1065,13 @@ test('{del} with a selection range', () => { input[value="hello"] - pointermove input[value="hello"] - mousemove input[value="hello"] - pointerdown - input[value="hello"] - mousedown + input[value="hello"] - mousedown: primary input[value="hello"] - focus input[value="hello"] - focusin input[value="hello"] - select input[value="hello"] - pointerup - input[value="hello"] - mouseup - input[value="hello"] - click + input[value="hello"] - mouseup: primary + input[value="hello"] - click: primary input[value="hello"] - select input[value="hello"] - keydown: Delete (46) input[value="hlo"] - select @@ -1121,12 +1121,12 @@ test('any remaining type modifiers are automatically released at the end', () => input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Meta (93) {meta} input[value=""] - keydown: Alt (18) {alt}{meta} input[value=""] - keydown: Control (17) {alt}{meta}{ctrl} @@ -1153,12 +1153,12 @@ test('modifiers will not be closed if skipAutoClose is enabled', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: Meta (93) {meta} input[value=""] - keydown: a (97) {meta} input[value=""] - keypress: a (97) {meta} diff --git a/tests/upload.js b/tests/upload.js index 1a9e051e..02d1a449 100644 --- a/tests/upload.js +++ b/tests/upload.js @@ -20,12 +20,12 @@ test('should fire the correct events for input', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - blur input[value=""] - focusout input[value=""] - focus @@ -55,11 +55,11 @@ test('should fire the correct events with label', () => { label[for="element"] - pointermove label[for="element"] - mousemove label[for="element"] - pointerdown - label[for="element"] - mousedown + label[for="element"] - mousedown: primary label[for="element"] - pointerup - label[for="element"] - mouseup - label[for="element"] - click - input#element[value=""] - click: Left (0) + label[for="element"] - mouseup: primary + label[for="element"] - click: primary + input#element[value=""] - click: primary input#element[value=""] - focusin input#element[value=""] - input input#element[value=""] - change diff --git a/tests/utils/edit/calculateNewValue.ts b/tests/utils/edit/calculateNewValue.ts index 7d1f4e50..fa5731ca 100644 --- a/tests/utils/edit/calculateNewValue.ts +++ b/tests/utils/edit/calculateNewValue.ts @@ -18,12 +18,12 @@ test('honors maxlength', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 1 (49) input[value=""] - keypress: 1 (49) input[value="1"] - input @@ -52,12 +52,12 @@ test('honors maxlength="" as if there was no maxlength', () => { input[value=""] - pointermove input[value=""] - mousemove input[value=""] - pointerdown - input[value=""] - mousedown + input[value=""] - mousedown: primary input[value=""] - focus input[value=""] - focusin input[value=""] - pointerup - input[value=""] - mouseup - input[value=""] - click + input[value=""] - mouseup: primary + input[value=""] - click: primary input[value=""] - keydown: 1 (49) input[value=""] - keypress: 1 (49) input[value="1"] - input @@ -90,13 +90,13 @@ test('honors maxlength with existing text', () => { input[value="12"] - pointermove input[value="12"] - mousemove input[value="12"] - pointerdown - input[value="12"] - mousedown + input[value="12"] - mousedown: primary input[value="12"] - focus input[value="12"] - focusin input[value="12"] - select input[value="12"] - pointerup - input[value="12"] - mouseup - input[value="12"] - click + input[value="12"] - mouseup: primary + input[value="12"] - click: primary input[value="12"] - keydown: 3 (51) input[value="12"] - keypress: 3 (51) input[value="12"] - keyup: 3 (51) @@ -120,13 +120,13 @@ test('honors maxlength on textarea', () => { textarea[value="12"] - pointermove textarea[value="12"] - mousemove textarea[value="12"] - pointerdown - textarea[value="12"] - mousedown + textarea[value="12"] - mousedown: primary textarea[value="12"] - focus textarea[value="12"] - focusin textarea[value="12"] - select textarea[value="12"] - pointerup - textarea[value="12"] - mouseup - textarea[value="12"] - click + textarea[value="12"] - mouseup: primary + textarea[value="12"] - click: primary textarea[value="12"] - keydown: 3 (51) textarea[value="12"] - keypress: 3 (51) textarea[value="12"] - keyup: 3 (51)