1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | import * as angular from 'angular';
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | declare module 'angular' {
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | interface IAngularStatic {
|
22 | mock: IMockStatic;
|
23 | }
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | interface IInjectStatic {
|
29 | (...fns: Array<Injectable<(...args: any[]) => void>>): any;
|
30 | strictDi(val?: boolean): any;
|
31 | }
|
32 |
|
33 | interface IMockStatic {
|
34 |
|
35 | dump(obj: any): string;
|
36 |
|
37 | inject: IInjectStatic;
|
38 |
|
39 |
|
40 | module: {
|
41 | (...modules: any[]): any;
|
42 | sharedInjector(): void;
|
43 | };
|
44 |
|
45 |
|
46 | TzDate(offset: number, timestamp: number | string): Date;
|
47 | }
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | interface IExceptionHandlerProvider extends IServiceProvider {
|
55 | mode(mode: string): void;
|
56 | }
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | interface ITimeoutService {
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | flush(delay?: number): void;
|
78 |
|
79 | |
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | verifyNoPendingTasks(): void;
|
97 | }
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | interface IIntervalService {
|
105 | |
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | flush(millis: number): number;
|
112 | }
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | interface ILogService {
|
120 | assertEmpty(): void;
|
121 | reset(): void;
|
122 | }
|
123 |
|
124 | interface ILogCall {
|
125 | logs: string[];
|
126 | }
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | interface IControllerService {
|
134 |
|
135 | <T>(
|
136 | controllerConstructor: (new (...args: any[]) => T) | ((...args: any[]) => T) | string,
|
137 | locals?: any,
|
138 | bindings?: any
|
139 | ): T;
|
140 | }
|
141 |
|
142 | ///////////////////////////////////////////////////////////////////////////
|
143 | // ComponentControllerService
|
144 | // see https://docs.angularjs.org/api/ngMock/service/$componentController
|
145 | ///////////////////////////////////////////////////////////////////////////
|
146 | interface IComponentControllerService {
|
147 | // TBinding is an interface exposed by a component as per John Papa's style guide
|
148 | // https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#accessible-members-up-top
|
149 | <T, TBinding>(
|
150 | componentName: string,
|
151 | locals: { $scope?: IScope | undefined; [key: string]: any },
|
152 | bindings?: TBinding,
|
153 | ident?: string
|
154 | ): T;
|
155 | }
|
156 |
|
157 | ///////////////////////////////////////////////////////////////////////////
|
158 | // HttpBackendService
|
159 | // see https://docs.angularjs.org/api/ngMock/service/$httpBackend
|
160 | ///////////////////////////////////////////////////////////////////////////
|
161 | interface IHttpBackendService {
|
162 | /**
|
163 | * Flushes pending requests using the trained responses. Requests are flushed in the order they
|
164 | * were made, but it is also possible to skip one or more requests (for example to have them
|
165 | * flushed later). This is useful for simulating scenarios where responses arrive from the server
|
166 | * in any order.
|
167 | *
|
168 | * If there are no pending requests to flush when the method is called, an exception is thrown (as
|
169 | * this is typically a sign of programming error).
|
170 | *
|
171 | * @param count Number of responses to flush. If undefined/null, all pending requests (starting
|
172 | * after `skip`) will be flushed.
|
173 | * @param skip Number of pending requests to skip. For example, a value of 5 would skip the first 5 pending requests and start flushing from the 6th onwards. _(default: 0)_
|
174 | */
|
175 | flush(count?: number, skip?: number): void;
|
176 |
|
177 | /**
|
178 | * Resets all request expectations, but preserves all backend definitions.
|
179 | */
|
180 | resetExpectations(): void;
|
181 |
|
182 | /**
|
183 | * Verifies that all of the requests defined via the `expect` api were made. If any of the
|
184 | * requests were not made, verifyNoOutstandingExpectation throws an exception.
|
185 | * @param digest Do digest before checking expectation. Pass anything except false to trigger digest.
|
186 | * NOTE: this flag is purposely undocumented by Angular, which means it's not to be used in normal client code.
|
187 | */
|
188 | verifyNoOutstandingExpectation(digest?: boolean): void;
|
189 |
|
190 | /**
|
191 | * Verifies that there are no outstanding requests that need to be flushed.
|
192 | */
|
193 | verifyNoOutstandingRequest(): void;
|
194 |
|
195 | /**
|
196 | * Creates a new request expectation.
|
197 | * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
198 | * Returns an object with respond method that controls how a matched request is handled.
|
199 | * @param method HTTP method.
|
200 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
201 | * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
202 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
203 | * @param keys Array of keys to assign to regex matches in the request url.
|
204 | */
|
205 | expect(
|
206 | method: string,
|
207 | url: string | RegExp | ((url: string) => boolean),
|
208 | data?: string | RegExp | object | ((data: string) => boolean),
|
209 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
210 | keys?: string[]
|
211 | ): mock.IRequestHandler;
|
212 |
|
213 | /**
|
214 | * Creates a new request expectation for DELETE requests.
|
215 | * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
216 | * Returns an object with respond method that controls how a matched request is handled.
|
217 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url is as expected.
|
218 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
219 | * @param keys Array of keys to assign to regex matches in the request url.
|
220 | */
|
221 | expectDELETE(
|
222 | url: string | RegExp | ((url: string) => boolean),
|
223 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
224 | keys?: string[]
|
225 | ): mock.IRequestHandler;
|
226 |
|
227 | /**
|
228 | * Creates a new request expectation for GET requests.
|
229 | * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
230 | * Returns an object with respond method that controls how a matched request is handled.
|
231 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
232 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
233 | * @param keys Array of keys to assign to regex matches in the request url.
|
234 | */
|
235 | expectGET(
|
236 | url: string | RegExp | ((url: string) => boolean),
|
237 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
238 | keys?: string[]
|
239 | ): mock.IRequestHandler;
|
240 |
|
241 | /**
|
242 | * Creates a new request expectation for HEAD requests.
|
243 | * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
244 | * Returns an object with respond method that controls how a matched request is handled.
|
245 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
246 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
247 | * @param keys Array of keys to assign to regex matches in the request url.
|
248 | */
|
249 |
|
250 | expectHEAD(
|
251 | url: string | RegExp | ((url: string) => boolean),
|
252 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
253 | keys?: string[]
|
254 | ): mock.IRequestHandler;
|
255 |
|
256 | /**
|
257 | * Creates a new request expectation for JSONP requests.
|
258 | * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false.
|
259 | * Returns an object with respond method that controls how a matched request is handled.
|
260 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
261 | * @param keys Array of keys to assign to regex matches in the request url.
|
262 | */
|
263 | expectJSONP(
|
264 | url: string | RegExp | ((url: string) => boolean),
|
265 | keys?: string[]
|
266 | ): mock.IRequestHandler;
|
267 |
|
268 | /**
|
269 | * Creates a new request expectation for PATCH requests.
|
270 | * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
271 | * Returns an object with respond method that controls how a matched request is handled.
|
272 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
273 | * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
274 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
275 | * @param keys Array of keys to assign to regex matches in the request url.
|
276 | */
|
277 | expectPATCH(
|
278 | url: string | RegExp | ((url: string) => boolean),
|
279 | data?: string | RegExp | object | ((data: string) => boolean),
|
280 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
281 | keys?: string[]
|
282 | ): mock.IRequestHandler;
|
283 |
|
284 | /**
|
285 | * Creates a new request expectation for POST requests.
|
286 | * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
287 | * Returns an object with respond method that controls how a matched request is handled.
|
288 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
289 | * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
290 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
291 | * @param keys Array of keys to assign to regex matches in the request url.
|
292 | */
|
293 | expectPOST(
|
294 | url: string | RegExp | ((url: string) => boolean),
|
295 | data?: string | RegExp | object | ((data: string) => boolean),
|
296 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
297 | keys?: string[]
|
298 | ): mock.IRequestHandler;
|
299 |
|
300 | /**
|
301 | * Creates a new request expectation for PUT requests.
|
302 | * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
303 | * Returns an object with respond method that controls how a matched request is handled.
|
304 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
305 | * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
306 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
307 | * @param keys Array of keys to assign to regex matches in the request url.
|
308 | */
|
309 | expectPUT(
|
310 | url: string | RegExp | ((url: string) => boolean),
|
311 | data?: string | RegExp | object | ((data: string) => boolean),
|
312 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
313 | keys?: string[]
|
314 | ): mock.IRequestHandler;
|
315 |
|
316 | /**
|
317 | * Creates a new request expectation that compares only with the requested route.
|
318 | * This method offers colon delimited matching of the url path, ignoring the query string.
|
319 | * This allows declarations similar to how application routes are configured with `$routeProvider`.
|
320 | * As this method converts the definition url to regex, declaration order is important.
|
321 | * @param method HTTP method
|
322 | * @param url HTTP url string that supports colon param matching
|
323 | */
|
324 | expectRoute(method: string, url: string): mock.IRequestHandler;
|
325 |
|
326 | /**
|
327 | * Creates a new backend definition.
|
328 | * Returns an object with respond method that controls how a matched request is handled.
|
329 | * @param method HTTP method.
|
330 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
331 | * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
332 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
333 | * @param keys Array of keys to assign to regex matches in the request url.
|
334 | */
|
335 | when(
|
336 | method: string,
|
337 | url: string | RegExp | ((url: string) => boolean),
|
338 | data?: string | RegExp | object | ((data: string) => boolean),
|
339 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
340 | keys?: string[]
|
341 | ): mock.IRequestHandler;
|
342 |
|
343 | /**
|
344 | * Creates a new backend definition for DELETE requests.
|
345 | * Returns an object with respond method that controls how a matched request is handled.
|
346 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
347 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
348 | * @param keys Array of keys to assign to regex matches in the request url.
|
349 | */
|
350 | whenDELETE(
|
351 | url: string | RegExp | ((url: string) => boolean),
|
352 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
353 | keys?: string[]
|
354 | ): mock.IRequestHandler;
|
355 |
|
356 | /**
|
357 | * Creates a new backend definition for GET requests.
|
358 | * Returns an object with respond method that controls how a matched request is handled.
|
359 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
360 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
361 | * @param keys Array of keys to assign to regex matches in request url described above
|
362 | * @param keys Array of keys to assign to regex matches in the request url.
|
363 | */
|
364 | whenGET(
|
365 | url: string | RegExp | ((url: string) => boolean),
|
366 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
367 | keys?: string[]
|
368 | ): mock.IRequestHandler;
|
369 |
|
370 | /**
|
371 | * Creates a new backend definition for HEAD requests.
|
372 | * Returns an object with respond method that controls how a matched request is handled.
|
373 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
374 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
375 | * @param keys Array of keys to assign to regex matches in the request url.
|
376 | */
|
377 | whenHEAD(
|
378 | url: string | RegExp | ((url: string) => boolean),
|
379 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
380 | keys?: string[]
|
381 | ): mock.IRequestHandler;
|
382 |
|
383 | /**
|
384 | * Creates a new backend definition for JSONP requests.
|
385 | * Returns an object with respond method that controls how a matched request is handled.
|
386 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
387 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
388 | * @param keys Array of keys to assign to regex matches in the request url.
|
389 | */
|
390 | whenJSONP(
|
391 | url: string | RegExp | ((url: string) => boolean),
|
392 | keys?: string[]
|
393 | ): mock.IRequestHandler;
|
394 |
|
395 | /**
|
396 | * Creates a new backend definition for PATCH requests.
|
397 | * Returns an object with respond method that controls how a matched request is handled.
|
398 | * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
399 | * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
400 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
401 | * @param keys Array of keys to assign to regex matches in the request url.
|
402 | */
|
403 | whenPATCH(
|
404 | url: string | RegExp | ((url: string) => boolean),
|
405 | data?: string | RegExp | object | ((data: string) => boolean),
|
406 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
407 | keys?: string[]
|
408 | ): mock.IRequestHandler;
|
409 |
|
410 | /**
|
411 | * Creates a new backend definition for POST requests.
|
412 | * Returns an object with respond method that controls how a matched request is handled.
|
413 | * @param url HTTP url string, regular expression or function that receives a url and returns true
|
414 | * if the url matches the current definition.
|
415 | * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
416 | * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
417 | * @param keys Array of keys to assign to regex matches in the request url.
|
418 | */
|
419 | whenPOST(
|
420 | url: string | RegExp | ((url: string) => boolean),
|
421 | data?: string | RegExp | object | ((data: string) => boolean),
|
422 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
423 | keys?: string[]
|
424 | ): mock.IRequestHandler;
|
425 |
|
426 | /**
|
427 | * Creates a new backend definition for PUT requests.
|
428 | * Returns an object with respond method that controls how a matched request is handled.
|
429 | * @param url HTTP url string, regular expression or function that receives a url and returns true
|
430 | * if the url matches the current definition.
|
431 | * @param data HTTP request body or function that receives data string and returns true if the data
|
432 | * is as expected.
|
433 | * @param headers HTTP headers or function that receives http header object and returns true if the
|
434 | * headers match the current definition.
|
435 | * @param keys Array of keys to assign to regex matches in the request url.
|
436 | */
|
437 | whenPUT(
|
438 | url: string | RegExp | ((url: string) => boolean),
|
439 | data?: string | RegExp | object | ((data: string) => boolean),
|
440 | headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
441 | keys?: string[]
|
442 | ): mock.IRequestHandler;
|
443 |
|
444 | /**
|
445 | * Creates a new backend definition that compares only with the requested route.
|
446 | * This method offers colon delimited matching of the url path, ignoring the query string.
|
447 | * This allows declarations similar to how application routes are configured with `$routeProvider`.
|
448 | * As this method converts the definition url to regex, declaration order is important.
|
449 | * @param method HTTP method.
|
450 | * @param url HTTP url string that supports colon param matching.
|
451 | */
|
452 | whenRoute(method: string, url: string): mock.IRequestHandler;
|
453 | }
|
454 |
|
455 | ///////////////////////////////////////////////////////////////////////////
|
456 | // FlushPendingTasksService
|
457 | // see https://docs.angularjs.org/api/ngMock/service/$flushPendingTasks
|
458 | ///////////////////////////////////////////////////////////////////////////
|
459 | interface IFlushPendingTasksService {
|
460 | /**
|
461 | * Flushes all currently pending tasks and executes the corresponding callbacks.
|
462 | *
|
463 | * Optionally, you can also pass a `delay` argument to only flush tasks that are scheduled to be
|
464 | * executed within `delay` milliseconds. Currently, `delay` only applies to timeouts, since all
|
465 | * other tasks have a delay of 0 (i.e. they are scheduled to be executed as soon as possible, but
|
466 | * still asynchronously).
|
467 | *
|
468 | * If no delay is specified, it uses a delay such that all currently pending tasks are flushed.
|
469 | *
|
470 | * The types of tasks that are flushed include:
|
471 | *
|
472 | * - Pending timeouts (via `$timeout`).
|
473 | * - Pending tasks scheduled via `$applyAsync`.
|
474 | * - Pending tasks scheduled via `$evalAsync`.
|
475 | * These include tasks scheduled via `$evalAsync()` indirectly (such as `$q` promises).
|
476 | *
|
477 | * > Periodic tasks scheduled via `$interval` use a different queue and are not flushed by
|
478 | * > `$flushPendingTasks()`. Use `$interval.flush(millis)` instead.
|
479 | *
|
480 | * @param millis - The number of milliseconds to flush.
|
481 | */
|
482 | (delay?: number): void;
|
483 | }
|
484 |
|
485 | ///////////////////////////////////////////////////////////////////////////
|
486 | // VerifyNoPendingTasksService
|
487 | // see https://docs.angularjs.org/api/ngMock/service/$verifyNoPendingTasks
|
488 | ///////////////////////////////////////////////////////////////////////////
|
489 | interface IVerifyNoPendingTasksService {
|
490 | /**
|
491 | * Verifies that there are no pending tasks that need to be flushed. It throws an error if there
|
492 | * are still pending tasks.
|
493 | *
|
494 | * You can check for a specific type of tasks only, by specifying a `taskType`.
|
495 | *
|
496 | * Available task types:
|
497 | *
|
498 | * - `$timeout`: Pending timeouts (via `$timeout`).
|
499 | * - `$http`: Pending HTTP requests (via `$http`).
|
500 | * - `$route`: In-progress route transitions (via `$route`).
|
501 | * - `$applyAsync`: Pending tasks scheduled via `$applyAsync`.
|
502 | * - `$evalAsync`: Pending tasks scheduled via `$evalAsync`.
|
503 | * These include tasks scheduled via `$evalAsync()` indirectly (such as `$q` promises).
|
504 | *
|
505 | * > Periodic tasks scheduled via `$interval` use a different queue and are not taken into
|
506 | * > account by `$verifyNoPendingTasks()`. There is currently no way to verify that there are no
|
507 | * > pending `$interval` tasks.
|
508 | *
|
509 | * @param taskType - The type of tasks to check for.
|
510 | */
|
511 | (taskType?: string): void;
|
512 | }
|
513 |
|
514 | ///////////////////////////////////////////////////////////////////////////
|
515 | // AnimateService
|
516 | // see https://docs.angularjs.org/api/ngMock/service/$animate
|
517 | ///////////////////////////////////////////////////////////////////////////
|
518 | namespace animate {
|
519 | interface IAnimateService {
|
520 | /**
|
521 | * This method will close all pending animations (both Javascript and CSS) and it will also flush any remaining
|
522 | * animation frames and/or callbacks.
|
523 | */
|
524 | closeAndFlush(): void;
|
525 |
|
526 | /**
|
527 | * This method is used to flush the pending callbacks and animation frames to either start
|
528 | * an animation or conclude an animation. Note that this will not actually close an
|
529 | * actively running animation (see `closeAndFlush()`} for that).
|
530 | */
|
531 | flush(): void;
|
532 | }
|
533 | }
|
534 |
|
535 | namespace mock {
|
536 | /** Object returned by the the mocked HttpBackendService expect/when methods */
|
537 | interface IRequestHandler {
|
538 | /**
|
539 | * Controls the response for a matched request using a function to construct the response.
|
540 | * Returns the RequestHandler object for possible overrides.
|
541 | * @param func Function that receives the request HTTP method, url, data, headers, and an array of keys
|
542 | * to regex matches in the request url and returns an array containing response status (number), data,
|
543 | * headers, and status text.
|
544 | */
|
545 | respond(
|
546 | func: ((
|
547 | method: string,
|
548 | url: string,
|
549 | data: string | object,
|
550 | headers: IHttpHeaders,
|
551 | params: { [key: string]: string }
|
552 | ) => [number, string | object, IHttpHeaders, string])
|
553 | ): IRequestHandler;
|
554 |
|
555 | /**
|
556 | * Controls the response for a matched request using supplied static data to construct the response.
|
557 | * Returns the RequestHandler object for possible overrides.
|
558 | * @param status HTTP status code to add to the response.
|
559 | * @param data Data to add to the response.
|
560 | * @param headers Headers object to add to the response.
|
561 | * @param responseText Response text to add to the response.
|
562 | */
|
563 | respond(
|
564 | status: number,
|
565 | data?: string | object,
|
566 | headers?: IHttpHeaders,
|
567 | responseText?: string
|
568 | ): IRequestHandler;
|
569 |
|
570 | /**
|
571 | * Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
|
572 | * Returns the RequestHandler object for possible overrides.
|
573 | * @param data Data to add to the response.
|
574 | * @param headers Headers object to add to the response.
|
575 | * @param responseText Response text to add to the response.
|
576 | */
|
577 | respond(
|
578 | data: string | object,
|
579 | headers?: IHttpHeaders,
|
580 | responseText?: string
|
581 | ): IRequestHandler;
|
582 |
|
583 | /**
|
584 | * Any request matching a backend definition or expectation with passThrough handler will be
|
585 | * passed through to the real backend (an XHR request will be made to the server.)
|
586 | * Available when ngMockE2E is loaded
|
587 | */
|
588 | passThrough(): IRequestHandler;
|
589 | }
|
590 |
|
591 | interface IHttpHeaders {
|
592 | [headerName: string]: any;
|
593 | }
|
594 |
|
595 | /**
|
596 | * Contains additional event data used by the `browserTrigger` function when creating an event.
|
597 | */
|
598 | interface IBrowserTriggerEventData {
|
599 | /**
|
600 | * [Event.bubbles](https:
|
601 | * Not applicable to all events.
|
602 | */
|
603 | bubbles?: boolean | undefined;
|
604 | |
605 |
|
606 |
|
607 |
|
608 | cancelable?: boolean | undefined;
|
609 | |
610 |
|
611 |
|
612 |
|
613 | charcode?: number | undefined;
|
614 | |
615 |
|
616 |
|
617 |
|
618 | data?: string | undefined;
|
619 | |
620 |
|
621 |
|
622 |
|
623 |
|
624 | elapsedTime?: number | undefined;
|
625 | |
626 |
|
627 |
|
628 |
|
629 | keycode?: number | undefined;
|
630 | |
631 |
|
632 |
|
633 |
|
634 |
|
635 | keys?: Array<'ctrl' | 'alt' | 'shift' | 'meta'> | undefined;
|
636 | |
637 |
|
638 |
|
639 |
|
640 | relatedTarget?: Node | undefined;
|
641 | |
642 |
|
643 |
|
644 |
|
645 | which?: number | undefined;
|
646 | |
647 |
|
648 |
|
649 |
|
650 | x?: number | undefined;
|
651 | |
652 |
|
653 |
|
654 |
|
655 | y?: number | undefined;
|
656 | }
|
657 | }
|
658 | }
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 | declare global {
|
666 | const inject: angular.IInjectStatic;
|
667 |
|
668 | |
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 | function browserTrigger(
|
679 | element: JQuery | Element,
|
680 | eventType?: string,
|
681 | eventData?: angular.mock.IBrowserTriggerEventData
|
682 | ): void;
|
683 | }
|
684 |
|
\ | No newline at end of file |