Skip to content

Commit

Permalink
test: add test for keyup
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 10, 2024
1 parent 71c74a6 commit 90848a7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/browser/test/userEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = []
Expand Down

0 comments on commit 90848a7

Please sign in to comment.