From 90848a71cbcf365c73ae0a9a5a011e74a04b6137 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Wed, 10 Jul 2024 17:25:32 +0200 Subject: [PATCH] test: add test for keyup --- test/browser/test/userEvent.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/browser/test/userEvent.test.ts b/test/browser/test/userEvent.test.ts index d71fd29b78d4..77363addd2e3 100644 --- a/test/browser/test/userEvent.test.ts +++ b/test/browser/test/userEvent.test.ts @@ -557,6 +557,22 @@ describe('userEvent.keyboard', async () => { ]) }) + test('should not auto release', async () => { + const spyKeydown = vi.fn() + const spyKeyup = vi.fn() + const button = document.createElement('button') + document.body.appendChild(button) + button.addEventListener('keydown', spyKeydown) + button.addEventListener('keyup', spyKeyup) + button.focus() + await userEvent.keyboard('{Enter>}') + expect(spyKeydown).toHaveBeenCalledOnce() + expect(spyKeyup).not.toHaveBeenCalled() + await userEvent.keyboard('{/Enter}') + // userEvent doesn't fire any event here, but should we? + expect(spyKeyup).not.toHaveBeenCalled() + }) + test('standalone keyboard works correctly with active input', async () => { const documentKeydown: string[] = [] const inputKeydown: string[] = []