Skip to content

Commit f77cb62

Browse files
authored
Merge branch 'master' into audit-types-package
2 parents c7eb91a + 5652374 commit f77cb62

14 files changed

Lines changed: 142 additions & 67 deletions

File tree

API.md

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ Emulating filling an input with text using `fillIn`
223223
fillIn('input', 'hello world');
224224
```
225225

226-
Returns **[Promise][66]<([Element][65] | void)>** resolves when the application is settled
226+
Returns **[Promise][66]\<void>** resolves when the application is settled
227227

228228
### focus
229229

@@ -311,7 +311,7 @@ keyboard.
311311

312312
#### Parameters
313313

314-
* `options` **[Object][72]?** optional tab behaviors
314+
* `options` **[Object][72]?** optional tab behaviors (optional, default `{}`)
315315

316316
* `options.backwards` **[boolean][71]** indicates if the the user navigates backwards (optional, default `false`)
317317
* `options.unRestrainTabIndex` **[boolean][71]** indicates if tabbing should throw an error when tabindex is greater than 0 (optional, default `false`)
@@ -376,7 +376,7 @@ Emulating tapping a button using `tap`
376376
tap('button');
377377
```
378378

379-
Returns **[Promise][66]<([Event][73] | [Array][70]<[Event][73]> | void)>** resolves when settled
379+
Returns **[Promise][66]\<void>** resolves when settled
380380

381381
### triggerEvent
382382

@@ -394,7 +394,7 @@ Using `triggerEvent` to upload a file
394394

395395
When using `triggerEvent` to upload a file the `eventType` must be `change` and you must pass the
396396
`options` param as an object with a key `files` containing an array of
397-
[Blob][74].
397+
[Blob][73].
398398

399399
```javascript
400400
triggerEvent(
@@ -406,8 +406,8 @@ triggerEvent(
406406

407407
Using `triggerEvent` to upload a dropped file
408408

409-
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][75],
410-
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][76].
409+
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][74],
410+
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][75].
411411

412412
```javascript
413413
triggerEvent(
@@ -426,8 +426,8 @@ Returns **[Promise][66]\<void>** resolves when the application is settled
426426
### triggerKeyEvent
427427

428428
Triggers a keyboard event of given type in the target element.
429-
It also requires the developer to provide either a string with the [`key`][77]
430-
or the numeric [`keyCode`][78] of the pressed key.
429+
It also requires the developer to provide either a string with the [`key`][76]
430+
or the numeric [`keyCode`][77] of the pressed key.
431431
Optionally the user can also provide a POJO with extra modifiers for the event.
432432

433433
#### Parameters
@@ -493,6 +493,14 @@ Find the first element matched by the given selector. Equivalent to calling
493493

494494
* `selector` **[string][64]** the selector to search for
495495

496+
#### Examples
497+
498+
Find all of the elements matching '.my-selector'.
499+
500+
```javascript
501+
findAll('.my-selector');
502+
```
503+
496504
Returns **[Element][65]** matched element or null
497505

498506
### findAll
@@ -505,12 +513,29 @@ of a `NodeList`.
505513

506514
* `selector` **[string][64]** the selector to search for
507515

516+
#### Examples
517+
518+
Finding the first element with id 'foo'
519+
520+
```javascript
521+
find('#foo');
522+
```
523+
508524
Returns **[Array][70]** array of matched elements
509525

510526
### getRootElement
511527

512528
Get the root element of the application under test (usually `#ember-testing`)
513529

530+
#### Examples
531+
532+
Getting the root element of the application and checking that it is equal
533+
to the element with id 'ember-testing'.
534+
535+
```javascript
536+
assert.equal(getRootElement(), document.querySelector('#ember-testing'));
537+
```
538+
514539
Returns **[Element][65]** the root element
515540

516541
## Routing Helpers
@@ -596,7 +621,7 @@ while *not* settled (e.g. "loading" or "pending" states).
596621

597622
#### Parameters
598623

599-
* `callback` **[Function][79]** the callback to use for testing when waiting should stop
624+
* `callback` **[Function][78]** the callback to use for testing when waiting should stop
600625
* `options` **[Object][72]?** options used to override defaults (optional, default `{}`)
601626

602627
* `options.timeout` **[number][69]** the maximum amount of time to wait (optional, default `1000`)
@@ -856,9 +881,9 @@ element).
856881

857882
#### Parameters
858883

859-
* `context` **[Object][72]** the context to setup for rendering
884+
* `context` **TestContext** the context to setup for rendering
860885

861-
Returns **[Promise][66]<[Object][72]>** resolves with the context that was setup
886+
Returns **[Promise][66]\<RenderingTestContext>** resolves with the context that was setup
862887

863888
### getApplication
864889

@@ -891,7 +916,7 @@ Sets up the basic framework used by application tests.
891916

892917
* `context` **[Object][72]** the context to setup
893918

894-
Returns **[Promise][66]<[Object][72]>** resolves with the context that was setup
919+
Returns **[Promise][66]\<void>** resolves when the context is set up
895920

896921
### validateErrorHandler
897922

@@ -906,7 +931,7 @@ everything is on fire...
906931

907932
#### Parameters
908933

909-
* `callback` **[Function][79]** the callback to validate (optional, default `Ember.onerror`)
934+
* `callback` **[Function][78]** the callback to validate (optional, default `Ember.onerror`)
910935

911936
#### Examples
912937

@@ -931,7 +956,7 @@ without an `onError` argument.
931956

932957
#### Parameters
933958

934-
* `onError` **[Function][79]** the onError function to be set on Ember.onerror
959+
* `onError` **[Function][78]** the onError function to be set on Ember.onerror
935960

936961
#### Examples
937962

@@ -1018,7 +1043,7 @@ Returns deprecations which have occured so far for a the current test context
10181043

10191044
### Parameters
10201045

1021-
* `callback` **CallableFunction?** The callback that when executed will have its DeprecationFailure recorded
1046+
* `callback` **[Function][78]?** The callback that when executed will have its DeprecationFailure recorded
10221047

10231048
### Examples
10241049

@@ -1076,7 +1101,7 @@ Returns warnings which have occured so far for a the current test context
10761101

10771102
### Parameters
10781103

1079-
* `callback` **CallableFunction?** The callback that when executed will have its warnings recorded
1104+
* `callback` **[Function][78]?** The callback that when executed will have its warnings recorded
10801105

10811106
### Examples
10821107

@@ -1216,23 +1241,23 @@ Returns **([Array][70]\<Warning> | [Promise][66]<[Array][70]\<Warning>>)** An ar
12161241

12171242
[54]: #getdeprecations
12181243

1219-
[55]: #examples-19
1244+
[55]: #examples-22
12201245

12211246
[56]: #getdeprecationsduringcallback
12221247

12231248
[57]: #parameters-29
12241249

1225-
[58]: #examples-20
1250+
[58]: #examples-23
12261251

12271252
[59]: #getwarnings
12281253

1229-
[60]: #examples-21
1254+
[60]: #examples-24
12301255

12311256
[61]: #getwarningsduringcallback
12321257

12331258
[62]: #parameters-30
12341259

1235-
[63]: #examples-22
1260+
[63]: #examples-25
12361261

12371262
[64]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
12381263

@@ -1252,16 +1277,14 @@ Returns **([Array][70]\<Warning> | [Promise][66]<[Array][70]\<Warning>>)** An ar
12521277

12531278
[72]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
12541279

1255-
[73]: https://developer.mozilla.org/docs/Web/API/Event
1256-
1257-
[74]: https://developer.mozilla.org/en-US/docs/Web/API/Blob
1280+
[73]: https://developer.mozilla.org/en-US/docs/Web/API/Blob
12581281

1259-
[75]: https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
1282+
[74]: https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
12601283

1261-
[76]: https://developer.mozilla.org/en-US/docs/Web/API/File
1284+
[75]: https://developer.mozilla.org/en-US/docs/Web/API/File
12621285

1263-
[77]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
1286+
[76]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
12641287

1265-
[78]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
1288+
[77]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
12661289

1267-
[79]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
1290+
[78]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

addon-test-support/@ember/test-helpers/dom/fill-in.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ registerHook('fillIn', 'start', (target: Target, text: string) => {
2121
@public
2222
@param {string|Element} target the element or selector to enter text into
2323
@param {string} text the text to fill into the target element
24-
@return {Promise<Element | void>} resolves when the application is settled
24+
@return {Promise<void>} resolves when the application is settled
2525
2626
@example
2727
<caption>
@@ -30,10 +30,7 @@ registerHook('fillIn', 'start', (target: Target, text: string) => {
3030
3131
fillIn('input', 'hello world');
3232
*/
33-
export default function fillIn(
34-
target: Target,
35-
text: string
36-
): Promise<Element | void> {
33+
export default function fillIn(target: Target, text: string): Promise<void> {
3734
return Promise.resolve()
3835
.then(() => runHooks('fillIn', 'start', target, text))
3936
.then(() => {

addon-test-support/@ember/test-helpers/dom/find-all.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ export default function findAll(selector: string): Element[];
2323
@public
2424
@param {string} selector the selector to search for
2525
@return {Array} array of matched elements
26+
27+
@example
28+
<caption>
29+
Finding the first element with id 'foo'
30+
</caption>
31+
find('#foo');
2632
*/
2733
export default function findAll(selector: string): Element[] {
2834
if (!selector) {

addon-test-support/@ember/test-helpers/dom/find.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ export default function find(selector: string): Element | null;
1818
@public
1919
@param {string} selector the selector to search for
2020
@return {Element | null} matched element or null
21+
22+
@example
23+
<caption>
24+
Find all of the elements matching '.my-selector'.
25+
</caption>
26+
findAll('.my-selector');
27+
2128
*/
2229
export default function find(selector: string): Element | null {
2330
if (!selector) {

addon-test-support/@ember/test-helpers/dom/get-root-element.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ import { isDocument, isElement } from './-target';
66
77
@public
88
@returns {Element} the root element
9+
10+
@example
11+
<caption>
12+
Getting the root element of the application and checking that it is equal
13+
to the element with id 'ember-testing'.
14+
</caption>
15+
assert.equal(getRootElement(), document.querySelector('#ember-testing'));
916
*/
1017
export default function getRootElement(): Element | Document {
1118
let context = getContext();

addon-test-support/@ember/test-helpers/dom/tab.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface InertHTMLElement extends HTMLElement {
3131
}
3232

3333
/**
34-
Compiles a list of nodes that can be focused. Walkes the tree, discardes hidden elements and a few edge cases. To calculate the right.
34+
Compiles a list of nodes that can be focused. Walks the tree, discards hidden elements and a few edge cases. To calculate the right.
3535
@private
3636
@param {Element} root the root element to start traversing on
3737
@returns {Array} list of focusable nodes
@@ -43,7 +43,7 @@ function compileFocusAreas(root: Element = document.body) {
4343
throw new Error('Element must be in the DOM');
4444
}
4545

46-
let activeElment = getActiveElement(ownerDocument);
46+
let activeElement = getActiveElement(ownerDocument);
4747
let treeWalker = ownerDocument.createTreeWalker(
4848
root,
4949
NodeFilter.SHOW_ELEMENT,
@@ -76,13 +76,13 @@ function compileFocusAreas(root: Element = document.body) {
7676
}
7777

7878
// Always accept the 'activeElement' of the document, as it might fail the next check, elements with tabindex="-1"
79-
// can be focused programtically, we'll therefor ensure the current active element is in the list.
80-
if (node === activeElment) {
79+
// can be focused programmatically, we'll therefor ensure the current active element is in the list.
80+
if (node === activeElement) {
8181
return NodeFilter.FILTER_ACCEPT;
8282
}
8383

8484
// UA parses the tabindex attribute and applies its default values, If the tabIndex is non negative, the UA can
85-
// foucs it.
85+
// focus it.
8686
return node.tabIndex >= 0
8787
? NodeFilter.FILTER_ACCEPT
8888
: NodeFilter.FILTER_SKIP;
@@ -173,14 +173,12 @@ function findNextResponders(root: Element, activeElement: HTMLElement) {
173173
</caption>
174174
tab({ backwards: true });
175175
*/
176-
export default function triggerTab(options?: {
177-
backwards: boolean;
178-
unRestrainTabIndex: boolean;
179-
}): Promise<void> {
176+
export default function triggerTab({
177+
backwards = false,
178+
unRestrainTabIndex = false,
179+
} = {}): Promise<void> {
180180
return Promise.resolve()
181181
.then(() => {
182-
let backwards = (options && options.backwards) || false;
183-
let unRestrainTabIndex = (options && options.unRestrainTabIndex) || false;
184182
return triggerResponderChange(backwards, unRestrainTabIndex);
185183
})
186184
.then(() => {
@@ -190,7 +188,7 @@ export default function triggerTab(options?: {
190188

191189
/**
192190
@private
193-
@param {boolean} backwards when `true` it selects the previous foucs area
191+
@param {boolean} backwards when `true` it selects the previous focus area
194192
@param {boolean} unRestrainTabIndex when `true`, will not throw an error if tabindex > 0 is encountered
195193
@returns {Promise<void>} resolves when all events are fired
196194
*/

addon-test-support/@ember/test-helpers/dom/tap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ registerHook('tap', 'start', (target: Target) => {
4545
@public
4646
@param {string|Element} target the element or selector to tap on
4747
@param {Object} options the options to be merged into the touch events
48-
@return {Promise<Event | Event[] | void>} resolves when settled
48+
@return {Promise<void>} resolves when settled
4949
5050
@example
5151
<caption>
@@ -57,7 +57,7 @@ registerHook('tap', 'start', (target: Target) => {
5757
export default function tap(
5858
target: Target,
5959
options: TouchEventInit = {}
60-
): Promise<Event | Event[] | void> {
60+
): Promise<void> {
6161
return Promise.resolve()
6262
.then(() => {
6363
return runHooks('tap', 'start', target, options);

0 commit comments

Comments
 (0)