Skip to content

Commit

Permalink
Revert changes to API.md; Add docs inline
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinten Powell committed Jun 7, 2019
1 parent bf014a4 commit 8de9e6d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
31 changes: 4 additions & 27 deletions API.md
Expand Up @@ -308,9 +308,8 @@ Triggers an event on the specified target.

#### Examples

Using `triggerEvent` to upload a file

When using `triggerEvent` to upload a file the `eventType` must be `change` and you must pass the
Using triggerEvent to Upload a file
When using triggerEvent to upload a file the `eventType` must be `change` and you must pass the
`options` param as an object with a key `files` containing an array of
[Blob][56].

Expand All @@ -319,29 +318,10 @@ When using `triggerEvent` to upload a file the `eventType` must be `change` and
triggerEvent(
'input.fileUpload',
'change',
{
files: [new Blob(['Ember Rules!'])]
}
[new Blob(['Ember Rules!'])]
);
```

Using `triggerEvent` to upload a dropped file

When using `triggerEvent` to handle a dropped (via drag-and-drop) file, the `eventType` must be `drop`. Assuming your `drop` event handler uses the [DataTransfer API][64], you must pass the `options` param as an object with a key of `dataTransfer`. The `options.dataTransfer` object should have a `files` key, containing an array of [File][63].

```javascript
triggerEvent(
'[data-test-drop-zone]',
'drop',
{
dataTransfer: {
files: [new File(['Ember Rules!', 'ember-rules.txt'])]
}
}
)
```


Returns **[Promise][53]<void>** resolves when the application is settled

### triggerKeyEvent
Expand Down Expand Up @@ -1003,7 +983,4 @@ QUnit.testDone(function() {

[61]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[62]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[63]: https://developer.mozilla.org/en-US/docs/Web/API/File
[64]: https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
[62]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
28 changes: 25 additions & 3 deletions addon-test-support/@ember/test-helpers/dom/trigger-event.ts
Expand Up @@ -14,16 +14,38 @@ import Target from './-target';
* @return {Promise<void>} resolves when the application is settled
*
* @example
* <caption>Using triggerEvent to Upload a file
* When using triggerEvent to upload a file the `eventType` must be `change` and you must pass the
* <caption>
* Using `triggerEvent` to upload a file
*
* When using `triggerEvent` to upload a file the `eventType` must be `change` and you must pass the
* `options` param as an object with a key `files` containing an array of
* [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob).</caption>
* [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
* </caption>
*
* triggerEvent(
* 'input.fileUpload',
* 'change',
* { files: [new Blob(['Ember Rules!'])] }
* );
*
*
* @example
* <caption>
* Using `triggerEvent` to upload a dropped file
*
* When using `triggerEvent` to handle a dropped (via drag-and-drop) file, the `eventType` must be `drop`. Assuming your `drop` event handler uses the [DataTransfer API](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer),
* you must pass the `options` param as an object with a key of `dataTransfer`. The `options.dataTransfer` object should have a `files` key, containing an array of [File](https://developer.mozilla.org/en-US/docs/Web/API/File).
* </caption>
*
* triggerEvent(
* '[data-test-drop-zone]',
* 'drop',
* {
* dataTransfer: {
* files: [new File(['Ember Rules!', 'ember-rules.txt'])]
* }
* }
* )
*/
export default function triggerEvent(
target: Target,
Expand Down

0 comments on commit 8de9e6d

Please sign in to comment.