Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for triggerEvent #663

Merged
merged 2 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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