Skip to content

Commit

Permalink
Add test case for interacting with elements with complex HTML IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyvoase committed Jul 29, 2024
1 parent 073a50c commit 3c666be
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/browser/test/userEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ describe('userEvent.click', () => {

expect(onClick).toHaveBeenCalled()
})

test('clicks a button with complex HTML ID', async () => {
const container = document.createElement('div')
// This is similar to unique IDs generated by React's useId()
container.id = ':r3:'
const button = document.createElement('button')
// Use uppercase and special characters
button.id = 'A:Button'
button.textContent = 'Click me'
container.appendChild(button)
document.body.appendChild(container)

const onClick = vi.fn()
const dblClick = vi.fn()
button.addEventListener('click', onClick)

await userEvent.click(button)

expect(onClick).toHaveBeenCalled()
expect(dblClick).not.toHaveBeenCalled()
});

Check failure on line 93 in test/browser/test/userEvent.test.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
})

describe('userEvent.dblClick', () => {
Expand Down

0 comments on commit 3c666be

Please sign in to comment.