import * as React from "react"; import { render } from "../render"; import { press } from "../press"; import { useAllEvents } from "./useAllEvents"; test("press enter on button", async () => { const stack = [] as string[]; const Test = () => { const ref = React.useRef(null); useAllEvents(ref, stack); return ; }; const { getByText } = render(); const button = getByText("button"); press.Enter(button); expect(stack).toMatchInlineSnapshot(` Array [ "focus button", "focusin button", "keydown button", "click button", "keyup button", ] `); }); test("press enter on button preventDefault", async () => { const stack = [] as string[]; const Test = () => { const ref = React.useRef(null); useAllEvents(ref, stack); return ( ); }; const { getByText } = render(); const button = getByText("button"); press.Enter(button); expect(stack).toMatchInlineSnapshot(` Array [ "focus button", "focusin button", "keydown button", "keyup button", ] `); }); test("press enter on textarea", () => { const stack = [] as string[]; const Test = () => { const ref = React.useRef(null); useAllEvents(ref, stack); return (
form