From 0d605cbdfc597e9209da2ae4d1da113dad3f85b3 Mon Sep 17 00:00:00 2001 From: jamsinclair Date: Fri, 8 May 2020 00:48:16 +0900 Subject: [PATCH] docs: add dataTransfer event property info --- docs/dom-testing-library/api-events.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/dom-testing-library/api-events.md b/docs/dom-testing-library/api-events.md index 9ccb901bf..2e6f972d6 100644 --- a/docs/dom-testing-library/api-events.md +++ b/docs/dom-testing-library/api-events.md @@ -59,6 +59,21 @@ fireEvent.change(getByLabelText(/picture/i), { }) ``` +**dataTransfer**: Drag events have a `dataTransfer` property that contains +data transferred during the operation. As a convenience, if you provide a +`dataTransfer` property in the `eventProperties` (second argument), then +those properties will be added to the event. + +This should predominantly be used for testing drag and drop interactions. + +```javascript +fireEvent.drop(getByLabelText(/drop files here/i), { + dataTransfer: { + files: [new File(['(⌐□_□)'], 'chucknorris.png', { type: 'image/png' })], + }, +}) +``` + **Keyboard events**: There are three event types related to keyboard input - `keyPress`, `keyDown`, and `keyUp`. When firing these you need to reference an element in the DOM and the key you want to fire.