Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update tests
  • Loading branch information
ph-fritsche committed Mar 31, 2022
commit 822debf0b272bd41065edbe9793bf017b8566413
14 changes: 14 additions & 0 deletions tests/pointer/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,17 @@ describe('focus control when clicking label', () => {
expect(input).not.toHaveFocus()
})
})

test('focus event handler can override selection', async () => {
const {element, user} = setup(`<input value="hello"/>`, {
focus: false,
})
element.addEventListener('focus', e =>
(e.target as HTMLInputElement).select(),
)

await user.click(element)

expect(element).toHaveProperty('selectionStart', 0)
expect(element).toHaveProperty('selectionEnd', 5)
})
2 changes: 1 addition & 1 deletion tests/utility/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ test('type into input', async () => {
input[value="foo"] - mousemove
input[value="foo"] - pointerdown
input[value="foo"] - mousedown: primary
input[value="foo"] - select
input[value="foo"] - focus
input[value="foo"] - focusin
input[value="foo"] - select
input[value="foo"] - pointerup
input[value="foo"] - mouseup: primary
input[value="foo"] - click: primary
Expand Down