mirror of
https://github.com/prymitive/karma
synced 2026-05-09 03:36:44 +00:00
23 lines
468 B
TypeScript
23 lines
468 B
TypeScript
import { act } from "react-dom/test-utils";
|
|
|
|
function PressKey(key: string, code: number): void {
|
|
act(() => {
|
|
document.dispatchEvent(
|
|
new KeyboardEvent("keydown", {
|
|
key: key,
|
|
keyCode: code,
|
|
which: code,
|
|
} as KeyboardEventInit)
|
|
);
|
|
document.dispatchEvent(
|
|
new KeyboardEvent("keyup", {
|
|
key: key,
|
|
keyCode: code,
|
|
which: code,
|
|
} as KeyboardEventInit)
|
|
);
|
|
});
|
|
}
|
|
|
|
export { PressKey };
|