diff --git a/API.md b/API.md index 8f795b28f..6e8a8302f 100644 --- a/API.md +++ b/API.md @@ -223,7 +223,7 @@ Emulating filling an input with text using `fillIn` fillIn('input', 'hello world'); ``` -Returns **[Promise][66]<([Element][65] | void)>** resolves when the application is settled +Returns **[Promise][66]\** resolves when the application is settled ### focus @@ -376,7 +376,7 @@ Emulating tapping a button using `tap` tap('button'); ``` -Returns **[Promise][66]<([Event][73] | [Array][70]<[Event][73]> | void)>** resolves when settled +Returns **[Promise][66]\** resolves when settled ### triggerEvent @@ -394,7 +394,7 @@ 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][74]. +[Blob][73]. ```javascript triggerEvent( @@ -406,8 +406,8 @@ triggerEvent( 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][75], -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]. +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], +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]. ```javascript triggerEvent( @@ -426,8 +426,8 @@ Returns **[Promise][66]\** resolves when the application is settled ### triggerKeyEvent Triggers a keyboard event of given type in the target element. -It also requires the developer to provide either a string with the [`key`][77] -or the numeric [`keyCode`][78] of the pressed key. +It also requires the developer to provide either a string with the [`key`][76] +or the numeric [`keyCode`][77] of the pressed key. Optionally the user can also provide a POJO with extra modifiers for the event. #### Parameters @@ -596,7 +596,7 @@ while *not* settled (e.g. "loading" or "pending" states). #### Parameters -* `callback` **[Function][79]** the callback to use for testing when waiting should stop +* `callback` **[Function][78]** the callback to use for testing when waiting should stop * `options` **[Object][72]?** options used to override defaults (optional, default `{}`) * `options.timeout` **[number][69]** the maximum amount of time to wait (optional, default `1000`) @@ -856,9 +856,9 @@ element). #### Parameters -* `context` **[Object][72]** the context to setup for rendering +* `context` **TestContext** the context to setup for rendering -Returns **[Promise][66]<[Object][72]>** resolves with the context that was setup +Returns **[Promise][66]\** resolves with the context that was setup ### getApplication @@ -906,7 +906,7 @@ everything is on fire... #### Parameters -* `callback` **[Function][79]** the callback to validate (optional, default `Ember.onerror`) +* `callback` **[Function][78]** the callback to validate (optional, default `Ember.onerror`) #### Examples @@ -931,7 +931,7 @@ without an `onError` argument. #### Parameters -* `onError` **[Function][79]** the onError function to be set on Ember.onerror +* `onError` **[Function][78]** the onError function to be set on Ember.onerror #### Examples @@ -1018,7 +1018,7 @@ Returns deprecations which have occured so far for a the current test context ### Parameters -* `callback` **[Function][79]?** The callback that when executed will have its DeprecationFailure recorded +* `callback` **[Function][78]?** The callback that when executed will have its DeprecationFailure recorded ### Examples @@ -1076,7 +1076,7 @@ Returns warnings which have occured so far for a the current test context ### Parameters -* `callback` **[Function][79]?** The callback that when executed will have its warnings recorded +* `callback` **[Function][78]?** The callback that when executed will have its warnings recorded ### Examples @@ -1252,16 +1252,14 @@ Returns **([Array][70]\ | [Promise][66]<[Array][70]\>)** An ar [72]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[73]: https://developer.mozilla.org/docs/Web/API/Event - -[74]: https://developer.mozilla.org/en-US/docs/Web/API/Blob +[73]: https://developer.mozilla.org/en-US/docs/Web/API/Blob -[75]: https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer +[74]: https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer -[76]: https://developer.mozilla.org/en-US/docs/Web/API/File +[75]: https://developer.mozilla.org/en-US/docs/Web/API/File -[77]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values +[76]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values -[78]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode +[77]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode -[79]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function +[78]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function diff --git a/addon-test-support/@ember/test-helpers/dom/fill-in.ts b/addon-test-support/@ember/test-helpers/dom/fill-in.ts index 97a998cfd..c4eac5007 100644 --- a/addon-test-support/@ember/test-helpers/dom/fill-in.ts +++ b/addon-test-support/@ember/test-helpers/dom/fill-in.ts @@ -21,7 +21,7 @@ registerHook('fillIn', 'start', (target: Target, text: string) => { @public @param {string|Element} target the element or selector to enter text into @param {string} text the text to fill into the target element - @return {Promise} resolves when the application is settled + @return {Promise} resolves when the application is settled @example @@ -30,10 +30,7 @@ registerHook('fillIn', 'start', (target: Target, text: string) => { fillIn('input', 'hello world'); */ -export default function fillIn( - target: Target, - text: string -): Promise { +export default function fillIn(target: Target, text: string): Promise { return Promise.resolve() .then(() => runHooks('fillIn', 'start', target, text)) .then(() => { diff --git a/addon-test-support/@ember/test-helpers/dom/tap.ts b/addon-test-support/@ember/test-helpers/dom/tap.ts index 20be8c671..f2910a3ef 100644 --- a/addon-test-support/@ember/test-helpers/dom/tap.ts +++ b/addon-test-support/@ember/test-helpers/dom/tap.ts @@ -45,7 +45,7 @@ registerHook('tap', 'start', (target: Target) => { @public @param {string|Element} target the element or selector to tap on @param {Object} options the options to be merged into the touch events - @return {Promise} resolves when settled + @return {Promise} resolves when settled @example @@ -57,7 +57,7 @@ registerHook('tap', 'start', (target: Target) => { export default function tap( target: Target, options: TouchEventInit = {} -): Promise { +): Promise { return Promise.resolve() .then(() => { return runHooks('tap', 'start', target, options); diff --git a/addon-test-support/@ember/test-helpers/index.ts b/addon-test-support/@ember/test-helpers/index.ts index dc2cfaa60..cc8af2a00 100644 --- a/addon-test-support/@ember/test-helpers/index.ts +++ b/addon-test-support/@ember/test-helpers/index.ts @@ -30,6 +30,7 @@ export { render, clearRender, } from './setup-rendering-context'; +export type { RenderingTestContext } from './setup-rendering-context'; export { default as rerender } from './rerender'; export { default as setupApplicationContext, diff --git a/addon-test-support/@ember/test-helpers/setup-rendering-context.ts b/addon-test-support/@ember/test-helpers/setup-rendering-context.ts index 50f828f80..00d0a526f 100644 --- a/addon-test-support/@ember/test-helpers/setup-rendering-context.ts +++ b/addon-test-support/@ember/test-helpers/setup-rendering-context.ts @@ -13,7 +13,7 @@ import settled from './settled'; import { hbs, TemplateFactory } from 'ember-cli-htmlbars'; import getRootElement from './dom/get-root-element'; import { Owner } from './build-owner'; -import getTestMetadata, { TestMetadata } from './test-metadata'; +import getTestMetadata from './test-metadata'; import { assert, deprecate } from '@ember/debug'; import { runHooks } from './-internal/helper-hooks'; import hasEmberVersion from './has-ember-version'; @@ -22,7 +22,6 @@ import { macroCondition, dependencySatisfies } from '@embroider/macros'; import { ComponentRenderMap, SetUsage } from './setup-context'; import { ensureSafeComponent } from '@embroider/util'; import type { ComponentInstance } from '@glimmer/interfaces'; -import ViewMixin from '@ember/component/-private/view-mixin'; const OUTLET_TEMPLATE = hbs`{{outlet}}`; const EMPTY_TEMPLATE = hbs``; @@ -32,8 +31,6 @@ export interface RenderingTestContext extends TestContext { render(template: TemplateFactory): Promise; clearRender(): Promise; - $?(selector: string): any; - element: Element | Document; } @@ -271,8 +268,8 @@ export function clearRender(): Promise { element). @public - @param {Object} context the context to setup for rendering - @returns {Promise} resolves with the context that was setup + @param {TestContext} context the context to setup for rendering + @returns {Promise} resolves with the context that was setup */ export default function setupRenderingContext( context: TestContext diff --git a/package.json b/package.json index 98a86b28c..a54b4f6b9 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "eslint-plugin-disable-features": "^0.1.3", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.2.1", - "expect-type": "^0.13.0", + "expect-type": "^0.15.0", "fs-extra": "^10.0.0", "latest-version": "^5.0.0", "loader.js": "^4.7.0", diff --git a/type-tests/api.ts b/type-tests/api.ts index 6a4299ab5..6377abe85 100644 --- a/type-tests/api.ts +++ b/type-tests/api.ts @@ -9,6 +9,7 @@ import { focus, scrollTo, select, + tab, tap, triggerEvent, triggerKeyEvent, @@ -45,6 +46,7 @@ import { unsetContext, teardownContext, setupRenderingContext, + RenderingTestContext, getApplication, setApplication, setupApplicationContext, @@ -63,7 +65,6 @@ import { DebugInfo as InternalDebugInfo, DeprecationFailure, Warning, - tab, } from '@ember/test-helpers'; import { ComponentInstance } from '@glimmer/interfaces'; import { Owner } from '@ember/test-helpers/build-owner'; @@ -219,7 +220,7 @@ expectTypeOf(teardownContext).toEqualTypeOf< ) => Promise >(); expectTypeOf(setupRenderingContext).toEqualTypeOf< - (context: TestContext) => Promise + (context: TestContext) => Promise >(); expectTypeOf(getApplication).toEqualTypeOf<() => Application | undefined>(); expectTypeOf(setApplication).toEqualTypeOf< diff --git a/yarn.lock b/yarn.lock index 4e90f3323..5533b9313 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6372,10 +6372,10 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: dependencies: homedir-polyfill "^1.0.1" -expect-type@^0.13.0: - version "0.13.0" - resolved "https://registry.yarnpkg.com/expect-type/-/expect-type-0.13.0.tgz#916646a7a73f3ee77039a634ee9035efe1876eb2" - integrity sha512-CclevazQfrqo8EvbLPmP7osnb1SZXkw47XPPvUUpeMz4HuGzDltE7CaIt3RLyT9UQrwVK/LDn+KVcC0hcgjgDg== +expect-type@^0.15.0: + version "0.15.0" + resolved "https://registry.yarnpkg.com/expect-type/-/expect-type-0.15.0.tgz#89f75e22c88554844ea2b2faf4ef5fc2e579d3b5" + integrity sha512-yWnriYB4e8G54M5/fAFj7rCIBiKs1HAACaY13kCz6Ku0dezjS9aMcfcdVK2X8Tv2tEV1BPz/wKfQ7WA4S/d8aA== express@^4.10.7, express@^4.18.1: version "4.18.2"