Skip to content

Commit 7bedb53

Browse files
authored
docs: add dataTransfer event property info (#459)
1 parent 61034fe commit 7bedb53

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/dom-testing-library/api-events.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ fireEvent.change(getByLabelText(/picture/i), {
5959
})
6060
```
6161

62+
**dataTransfer**: Drag events have a `dataTransfer` property that contains
63+
data transferred during the operation. As a convenience, if you provide a
64+
`dataTransfer` property in the `eventProperties` (second argument), then
65+
those properties will be added to the event.
66+
67+
This should predominantly be used for testing drag and drop interactions.
68+
69+
```javascript
70+
fireEvent.drop(getByLabelText(/drop files here/i), {
71+
dataTransfer: {
72+
files: [new File(['(⌐□_□)'], 'chucknorris.png', { type: 'image/png' })],
73+
},
74+
})
75+
```
76+
6277
**Keyboard events**: There are three event types related to keyboard input -
6378
`keyPress`, `keyDown`, and `keyUp`. When firing these you need to reference an
6479
element in the DOM and the key you want to fire.

0 commit comments

Comments
 (0)