Skip to content

Commit

Permalink
test: prevent file dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche committed Feb 4, 2022
1 parent 9edb15f commit ab1361e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/utility/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ test('relay click/upload on label to file input', async () => {
`)
})

test('prevent file dialog per click event handler', async () => {
const file = new File(['hello'], 'hello.png', {type: 'image/png'})

const {
elements: [label, input],
eventWasFired,
} = setup<[HTMLLabelElement]>(`
<label for="element">Element</label>
<input type="file" id="element" />
`)
input.addEventListener('click', e => e.preventDefault())

await userEvent.upload(label, file)

expect(eventWasFired('input')).toBe(false)
})

test('upload multiple files', async () => {
const files = [
new File(['hello'], 'hello.png', {type: 'image/png'}),
Expand Down

0 comments on commit ab1361e

Please sign in to comment.