-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: APIs always return a Promise.
- Loading branch information
1 parent
b754dd4
commit ca214d4
Showing
84 changed files
with
1,729 additions
and
2,076 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type {PointerInput} from '../pointer' | ||
import {hasPointerEvents} from '../utils' | ||
import {Config, UserEvent} from '../setup' | ||
|
||
export async function click(this: UserEvent, element: Element): Promise<void> { | ||
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) { | ||
throw new Error( | ||
'unable to click element as it has or inherits pointer-events set to "none".', | ||
) | ||
} | ||
|
||
const pointerIn: PointerInput = [] | ||
if (!this[Config].skipHover) { | ||
pointerIn.push({target: element}) | ||
} | ||
pointerIn.push({keys: '[MouseLeft]', target: element}) | ||
|
||
return this.pointer(pointerIn) | ||
} | ||
|
||
export async function dblClick( | ||
this: UserEvent, | ||
element: Element, | ||
): Promise<void> { | ||
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) { | ||
throw new Error( | ||
'unable to double-click element as it has or inherits pointer-events set to "none".', | ||
) | ||
} | ||
|
||
return this.pointer([{target: element}, '[MouseLeft][MouseLeft]']) | ||
} | ||
|
||
export async function tripleClick( | ||
this: UserEvent, | ||
element: Element, | ||
): Promise<void> { | ||
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) { | ||
throw new Error( | ||
'unable to triple-click element as it has or inherits pointer-events set to "none".', | ||
) | ||
} | ||
|
||
return this.pointer([{target: element}, '[MouseLeft][MouseLeft][MouseLeft]']) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {Config, UserEvent} from '../setup' | ||
import {hasPointerEvents} from '../utils' | ||
|
||
export async function hover(this: UserEvent, element: Element) { | ||
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) { | ||
throw new Error( | ||
'unable to hover element as it has or inherits pointer-events set to "none".', | ||
) | ||
} | ||
|
||
return this.pointer({target: element}) | ||
} | ||
|
||
export async function unhover(this: UserEvent, element: Element) { | ||
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) { | ||
throw new Error( | ||
'unable to unhover element as it has or inherits pointer-events set to "none".', | ||
) | ||
} | ||
|
||
return this.pointer({target: element.ownerDocument.body}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './click' | ||
export * from './hover' | ||
export * from './tab' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type {UserEvent} from '../setup' | ||
|
||
export async function tab( | ||
this: UserEvent, | ||
{ | ||
shift, | ||
}: { | ||
shift?: boolean | ||
} = {}, | ||
) { | ||
return this.keyboard( | ||
shift === true | ||
? '{Shift>}{Tab}{/Shift}' | ||
: shift === false | ||
? '[/ShiftLeft][/ShiftRight]{Tab}' | ||
: '{Tab}', | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
import {userEventApis, UserEventApis, setup, UserEvent} from './setup' | ||
|
||
const userEvent: UserEventApis & { | ||
setup: typeof setup | ||
} = { | ||
...(Object.fromEntries( | ||
Object.entries(userEventApis).map(([k, f]) => [ | ||
k, | ||
(...a: unknown[]) => | ||
(f as (this: UserEvent, ...b: unknown[]) => unknown).apply( | ||
userEvent, | ||
a, | ||
), | ||
]), | ||
) as UserEventApis), | ||
setup, | ||
} | ||
|
||
export default userEvent | ||
|
||
export {userEvent as default} from './setup' | ||
export type {keyboardKey} from './keyboard' | ||
export type {pointerKey} from './pointer' |
Oops, something went wrong.