0

I use Hotkey Provider from Blueprint JS (blueprint js docs), and I'm not sure how to test it.

It was something like :

<HotkeysTarget2 hotkeys={hotkeys}>
  {({ handleKeyDown, handleKeyUp }) => (
     <div onKeyDown={handleKeyDown} onKeyUp={handleKeyUp}>
       {/* code... */}
     </div>
  )}
</HotkeysTarget2>

hotkeys :

{
 combo: "1",
 global: true,
 label: "Press button 1",
 onKeyUp: () => fillText("button 1 pressed"), // Here is function to fill html input
},

I have tried to write a test case like this :

describe("test", () => {
  it("should response when press button 1", () => {
    const inputField = screen.getByTestId("pressed-button");
    userEvent.keyboard("{1}");
    expect(inputField).toHaveDisplayValue("button 1 pressed")
  });
});

But it doesn't work. Does anyone have similar issues (or maybe related issues)?

0 Answers0