Skip to content

Commit

Permalink
Update 'triggerEvent' examples (#663)
Browse files Browse the repository at this point in the history
Update 'triggerEvent' examples
  • Loading branch information
rwjblue authored Jun 11, 2019
2 parents 9331615 + 8de9e6d commit fe81329
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -983,4 +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
[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
Original file line number Diff line number Diff line change
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 fe81329

Please sign in to comment.