1 | import { expectTypeOf } from 'expect-type';
|
2 |
|
3 | import {
|
4 |
|
5 | blur,
|
6 | click,
|
7 | doubleClick,
|
8 | fillIn,
|
9 | focus,
|
10 | scrollTo,
|
11 | select,
|
12 | tab,
|
13 | tap,
|
14 | triggerEvent,
|
15 | triggerKeyEvent,
|
16 | typeIn,
|
17 |
|
18 | find,
|
19 | findAll,
|
20 | getRootElement,
|
21 |
|
22 | visit,
|
23 | currentRouteName,
|
24 | currentURL,
|
25 |
|
26 | render,
|
27 | rerender,
|
28 | clearRender,
|
29 |
|
30 | waitFor,
|
31 | waitUntil,
|
32 | settled,
|
33 | isSettled,
|
34 | getSettledState,
|
35 |
|
36 | pauseTest,
|
37 | resumeTest,
|
38 |
|
39 | getDebugInfo,
|
40 | registerDebugInfoHelper,
|
41 |
|
42 | setResolver,
|
43 | getResolver,
|
44 | setupContext,
|
45 | getContext,
|
46 | setContext,
|
47 | unsetContext,
|
48 | teardownContext,
|
49 | setupRenderingContext,
|
50 | RenderingTestContext,
|
51 | getApplication,
|
52 | setApplication,
|
53 | setupApplicationContext,
|
54 | validateErrorHandler,
|
55 | setupOnerror,
|
56 | resetOnerror,
|
57 | getTestMetadata,
|
58 |
|
59 | getDeprecations,
|
60 | getDeprecationsDuringCallback,
|
61 | getWarnings,
|
62 | getWarningsDuringCallback,
|
63 | BaseContext,
|
64 | TestContext,
|
65 | TestMetadata,
|
66 | DebugInfo as InternalDebugInfo,
|
67 | DeprecationFailure,
|
68 | Warning,
|
69 | Target,
|
70 |
|
71 | registerHook,
|
72 | runHooks,
|
73 | type Hook,
|
74 | type HookLabel,
|
75 | type HookUnregister,
|
76 | } from '@ember/test-helpers';
|
77 | import { ComponentInstance } from '@glimmer/interfaces';
|
78 | import { Owner } from '@ember/test-helpers/build-owner';
|
79 | import { DebugInfo as BackburnerDebugInfo } from '@ember/runloop/-private/backburner';
|
80 | import type { Resolver as EmberResolver } from '@ember/owner';
|
81 | import Application from '@ember/application';
|
82 | import { TemplateFactory } from 'ember-cli-htmlbars';
|
83 | import type { IDOMElementDescriptor } from 'dom-element-descriptors';
|
84 |
|
85 |
|
86 | expectTypeOf(blur).toEqualTypeOf<(target?: Target) => Promise<void>>();
|
87 | expectTypeOf(click).toEqualTypeOf<
|
88 | (target: Target, options?: MouseEventInit) => Promise<void>
|
89 | >();
|
90 | expectTypeOf(doubleClick).toEqualTypeOf<
|
91 | (target: Target, options?: MouseEventInit) => Promise<void>
|
92 | >();
|
93 | expectTypeOf(fillIn).toEqualTypeOf<
|
94 | (target: Target, text: string) => Promise<void>
|
95 | >();
|
96 | expectTypeOf(focus).toEqualTypeOf<(target: Target) => Promise<void>>();
|
97 | expectTypeOf(scrollTo).toEqualTypeOf<
|
98 | (
|
99 | target: string | HTMLElement | IDOMElementDescriptor,
|
100 | x: number,
|
101 | y: number
|
102 | ) => Promise<void>
|
103 | >();
|
104 | expectTypeOf(select).toEqualTypeOf<
|
105 | (
|
106 | target: Target,
|
107 | options: string | string[],
|
108 | keepPreviouslySelected?: boolean
|
109 | ) => Promise<void>
|
110 | >();
|
111 | expectTypeOf(tab).toEqualTypeOf<
|
112 | ({
|
113 | backwards,
|
114 | unRestrainTabIndex,
|
115 | }?: {
|
116 | backwards?: boolean | undefined;
|
117 | unRestrainTabIndex?: boolean | undefined;
|
118 | }) => Promise<void>
|
119 | >();
|
120 | expectTypeOf(tap).toEqualTypeOf<
|
121 | (target: Target, options?: TouchEventInit) => Promise<void>
|
122 | >();
|
123 | expectTypeOf(triggerEvent).toEqualTypeOf<
|
124 | (
|
125 | target: Target,
|
126 | eventType: string,
|
127 | options?: Record<string, unknown>
|
128 | ) => Promise<void>
|
129 | >();
|
130 | expectTypeOf(triggerKeyEvent).toEqualTypeOf<
|
131 | (
|
132 | target: Target,
|
133 | eventType: 'keydown' | 'keyup' | 'keypress',
|
134 | key: number | string,
|
135 | modifiers?: {
|
136 | ctrlKey?: boolean;
|
137 | altKey?: boolean;
|
138 | shiftKey?: boolean;
|
139 | metaKey?: boolean;
|
140 | }
|
141 | ) => Promise<void>
|
142 | >();
|
143 | expectTypeOf(typeIn).toEqualTypeOf<
|
144 | (
|
145 | target: Target,
|
146 | text: string,
|
147 | options?: {
|
148 | delay?: number;
|
149 | }
|
150 | ) => Promise<void>
|
151 | >();
|
152 |
|
153 |
|
154 | expectTypeOf(find).toEqualTypeOf<Document['querySelector']>();
|
155 | expectTypeOf(find('a')).toEqualTypeOf<HTMLAnchorElement | SVGAElement | null>();
|
156 | expectTypeOf(find('div')).toEqualTypeOf<HTMLDivElement | null>();
|
157 | expectTypeOf(find('circle')).toEqualTypeOf<SVGCircleElement | null>();
|
158 | expectTypeOf(find('.corkscrew')).toEqualTypeOf<Element | null>();
|
159 | expectTypeOf(findAll).toEqualTypeOf<(selector: string) => Array<Element>>();
|
160 | expectTypeOf(findAll('a')).toEqualTypeOf<(HTMLAnchorElement | SVGAElement)[]>();
|
161 | expectTypeOf(findAll('div')).toEqualTypeOf<HTMLDivElement[]>();
|
162 | expectTypeOf(findAll('circle')).toEqualTypeOf<SVGCircleElement[]>();
|
163 | expectTypeOf(findAll('.corkscrew')).toEqualTypeOf<Element[]>();
|
164 | expectTypeOf(getRootElement).toEqualTypeOf<() => Element | Document>();
|
165 |
|
166 |
|
167 | expectTypeOf(visit).toEqualTypeOf<
|
168 | (url: string, options?: Record<string, unknown>) => Promise<void>
|
169 | >();
|
170 | expectTypeOf(currentRouteName).toEqualTypeOf<() => string>();
|
171 | expectTypeOf(currentURL).toEqualTypeOf<() => string>();
|
172 |
|
173 |
|
174 | expectTypeOf(render).toMatchTypeOf<
|
175 | (templateOrComponent: object, options?: { owner?: Owner }) => Promise<void>
|
176 | >();
|
177 | expectTypeOf(rerender).toMatchTypeOf<() => Promise<void>>();
|
178 | expectTypeOf(clearRender).toEqualTypeOf<() => Promise<void>>();
|
179 |
|
180 |
|
181 | expectTypeOf(waitFor).toEqualTypeOf<
|
182 | (
|
183 | selector: string | IDOMElementDescriptor,
|
184 | options?: {
|
185 | timeout?: number;
|
186 | count?: number | null;
|
187 | timeoutMessage?: string;
|
188 | }
|
189 | ) => Promise<Element | Array<Element>>
|
190 | >();
|
191 | expectTypeOf(waitUntil).toEqualTypeOf<
|
192 | <T>(
|
193 | callback: () => T | void | false | 0 | '' | null | undefined,
|
194 | options?: {
|
195 | timeout?: number;
|
196 | timeoutMessage?: string;
|
197 | }
|
198 | ) => Promise<T>
|
199 | >();
|
200 | expectTypeOf(settled).toEqualTypeOf<() => Promise<void>>();
|
201 | expectTypeOf(isSettled).toEqualTypeOf<() => boolean>();
|
202 | expectTypeOf(getSettledState).toEqualTypeOf<
|
203 | () => {
|
204 | hasRunLoop: boolean;
|
205 | hasPendingTimers: boolean;
|
206 | hasPendingWaiters: boolean;
|
207 | hasPendingRequests: boolean;
|
208 | hasPendingTransitions: boolean | null;
|
209 | isRenderPending: boolean;
|
210 | pendingRequestCount: number;
|
211 | debugInfo: InternalDebugInfo;
|
212 | }
|
213 | >();
|
214 |
|
215 |
|
216 | expectTypeOf(pauseTest).toEqualTypeOf<() => Promise<void>>();
|
217 | expectTypeOf(resumeTest).toEqualTypeOf<() => void>();
|
218 |
|
219 |
|
220 | expectTypeOf(getDebugInfo).toEqualTypeOf<() => BackburnerDebugInfo | null>();
|
221 | expectTypeOf(registerDebugInfoHelper).toEqualTypeOf<
|
222 | (debugInfoHelper: { name: string; log: () => void }) => void
|
223 | >();
|
224 |
|
225 |
|
226 | expectTypeOf(setResolver).toEqualTypeOf<(resolver: EmberResolver) => void>();
|
227 | expectTypeOf(getResolver).toEqualTypeOf<() => EmberResolver | undefined>();
|
228 | expectTypeOf(setupContext).toEqualTypeOf<
|
229 | (
|
230 | context: BaseContext,
|
231 | options?: { resolver?: EmberResolver }
|
232 | ) => Promise<TestContext>
|
233 | >();
|
234 | expectTypeOf(getContext).toEqualTypeOf<() => BaseContext | undefined>();
|
235 | expectTypeOf(setContext).toEqualTypeOf<(context: BaseContext) => void>();
|
236 | expectTypeOf(unsetContext).toEqualTypeOf<() => void>();
|
237 | expectTypeOf(teardownContext).toEqualTypeOf<
|
238 | (
|
239 | context: TestContext,
|
240 | options?: { waitForSettled?: boolean }
|
241 | ) => Promise<void>
|
242 | >();
|
243 | expectTypeOf(setupRenderingContext).toEqualTypeOf<
|
244 | (context: TestContext) => Promise<RenderingTestContext>
|
245 | >();
|
246 | expectTypeOf(getApplication).toEqualTypeOf<() => Application | undefined>();
|
247 | expectTypeOf(setApplication).toEqualTypeOf<
|
248 | (application: Application) => void
|
249 | >();
|
250 | expectTypeOf(setupApplicationContext).toEqualTypeOf<
|
251 | (context: TestContext) => Promise<void>
|
252 | >();
|
253 | expectTypeOf(validateErrorHandler).toMatchTypeOf<
|
254 | (
|
255 | callback?: (error: Error) => void
|
256 | ) =>
|
257 | | Readonly<{ isValid: true; message: null }>
|
258 | | Readonly<{ isValid: false; message: string }>
|
259 | >();
|
260 | expectTypeOf(setupOnerror).toEqualTypeOf<
|
261 | (onError?: (error: Error) => void) => void
|
262 | >();
|
263 | expectTypeOf(resetOnerror).toEqualTypeOf<() => void>();
|
264 | expectTypeOf(getTestMetadata).toEqualTypeOf<
|
265 | (context: BaseContext) => TestMetadata
|
266 | >();
|
267 |
|
268 |
|
269 | expectTypeOf(getDeprecations).toEqualTypeOf<() => Array<DeprecationFailure>>();
|
270 | expectTypeOf(getDeprecationsDuringCallback).toEqualTypeOf<
|
271 | (
|
272 | callback: () => void
|
273 | ) => Array<DeprecationFailure> | Promise<Array<DeprecationFailure>>
|
274 | >();
|
275 | expectTypeOf(getWarnings).toEqualTypeOf<() => Array<Warning>>();
|
276 | expectTypeOf(getWarningsDuringCallback).toEqualTypeOf<
|
277 | (callback: () => void) => Array<Warning> | Promise<Array<Warning>>
|
278 | >();
|
279 |
|
280 |
|
281 | expectTypeOf(registerHook).toEqualTypeOf<
|
282 | (helperName: string, label: HookLabel, hook: Hook) => HookUnregister
|
283 | >();
|
284 | expectTypeOf(runHooks).toEqualTypeOf<
|
285 | (helperName: string, label: HookLabel, ...args: unknown[]) => Promise<void>
|
286 | >();
|