Files
karma/ui/src/__fixtures__/PressKey.ts
2020-10-28 12:26:51 +00:00

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 };