diff --git a/packages/use-keyboard-events/src/handlers.test.tsx b/packages/use-keyboard-events/src/handlers.test.tsx index 546fc5d4..4e8a267a 100644 --- a/packages/use-keyboard-events/src/handlers.test.tsx +++ b/packages/use-keyboard-events/src/handlers.test.tsx @@ -171,6 +171,38 @@ describe('@acusti/use-keyboard-events', () => { fireEvent.keyDown(getByText(text), { key: 'A', code: 'KeyA' }); expect(isUsingKeyEvent).toBe(false); }); + + it('detects that range s use arrow key events', async () => { + const user = userEvent.setup(); + const { getByRole } = render( + , + ); + const input = getByRole('slider'); + expect(isUsingKeyEvent).toBe(null); + await user.type(input, 'A'); + expect(isUsingKeyEvent).toBe(false); + isUsingKeyEvent = null; + await user.type(input, '{ArrowDown}'); + expect(isUsingKeyEvent).toBe(true); + isUsingKeyEvent = null; + expect(isUsingKeyEvent).toBe(null); + await user.type(input, '{ArrowRight}'); + expect(isUsingKeyEvent).toBe(true); + }); + + it('detects that checkbox s use spacebar and enter events', async () => { + const user = userEvent.setup(); + const { getByRole } = render( + , + ); + const input = getByRole('checkbox'); + expect(isUsingKeyEvent).toBe(null); + await user.type(input, 'A'); + expect(isUsingKeyEvent).toBe(false); + isUsingKeyEvent = null; + await user.type(input, ' '); + expect(isUsingKeyEvent).toBe(true); + }); }); }); });