1
- // Type definitions for Angular JS (ngMock, ngMockE2E module) 1.6
1
+ // Type definitions for Angular JS (ngMock, ngMockE2E module) 1.7
2
2
// Project: http://angularjs.org
3
3
// Definitions by: Diego Vilar <https://github.com/diegovilar>, Tony Curtis <https://github.com/daltin>
4
4
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -59,7 +59,38 @@ declare module 'angular' {
59
59
// Augments the original service
60
60
///////////////////////////////////////////////////////////////////////////
61
61
interface ITimeoutService {
62
+ /**
63
+ * **Deprecated** since version 1.7.3. (Use `$flushPendingTasks` instead.)
64
+ *
65
+ * ---
66
+ * Flushes the queue of pending tasks.
67
+ *
68
+ * _This method is essentially an alias of `$flushPendingTasks`._
69
+ *
70
+ * > For historical reasons, this method will also flush non-`$timeout` pending tasks, such as
71
+ * > `$q` promises and tasks scheduled via `$applyAsync` and `$evalAsync`.
72
+ *
73
+ * @param delay - The maximum timeout amount to flush up until.
74
+ */
62
75
flush ( delay ?: number ) : void ;
76
+
77
+ /**
78
+ * **Deprecated** since version 1.7.3. (Use `$verifyNoPendingTasks` instead.)
79
+ *
80
+ * ---
81
+ * Verifies that there are no pending tasks that need to be flushed. It throws an error if there
82
+ * are still pending tasks.
83
+ *
84
+ * _This method is essentially an alias of `$verifyNoPendingTasks` (called with no arguments)._
85
+ *
86
+ * > For historical reasons, this method will also verify non-`$timeout` pending tasks, such as
87
+ * > pending `$http` requests, in-progress `$route` transitions, unresolved `$q` promises and
88
+ * > tasks scheduled via `$applyAsync` and `$evalAsync`.
89
+ * >
90
+ * > It is recommended to use `$verifyNoPendingTasks` instead, which additionally supports
91
+ * > verifying a specific type of tasks. For example, you can verify there are no pending
92
+ * > timeouts with `$verifyNoPendingTasks('$timeout')`.
93
+ */
63
94
verifyNoPendingTasks ( ) : void ;
64
95
}
65
96
@@ -69,7 +100,13 @@ declare module 'angular' {
69
100
// Augments the original service
70
101
///////////////////////////////////////////////////////////////////////////
71
102
interface IIntervalService {
72
- flush ( millis ?: number ) : number ;
103
+ /**
104
+ * Runs interval tasks scheduled to be run in the next `millis` milliseconds.
105
+ *
106
+ * @param millis - The maximum timeout amount to flush up until.
107
+ * @return The amount of time moved forward.
108
+ */
109
+ flush ( millis : number ) : number ;
73
110
}
74
111
75
112
///////////////////////////////////////////////////////////////////////////
@@ -413,6 +450,65 @@ declare module 'angular' {
413
450
whenRoute ( method : string , url : string ) : mock . IRequestHandler ;
414
451
}
415
452
453
+ ///////////////////////////////////////////////////////////////////////////
454
+ // FlushPendingTasksService
455
+ // see https://docs.angularjs.org/api/ngMock/service/$flushPendingTasks
456
+ ///////////////////////////////////////////////////////////////////////////
457
+ interface IFlushPendingTasksService {
458
+ /**
459
+ * Flushes all currently pending tasks and executes the corresponding callbacks.
460
+ *
461
+ * Optionally, you can also pass a `delay` argument to only flush tasks that are scheduled to be
462
+ * executed within `delay` milliseconds. Currently, `delay` only applies to timeouts, since all
463
+ * other tasks have a delay of 0 (i.e. they are scheduled to be executed as soon as possible, but
464
+ * still asynchronously).
465
+ *
466
+ * If no delay is specified, it uses a delay such that all currently pending tasks are flushed.
467
+ *
468
+ * The types of tasks that are flushed include:
469
+ *
470
+ * - Pending timeouts (via `$timeout`).
471
+ * - Pending tasks scheduled via `$applyAsync`.
472
+ * - Pending tasks scheduled via `$evalAsync`.
473
+ * These include tasks scheduled via `$evalAsync()` indirectly (such as `$q` promises).
474
+ *
475
+ * > Periodic tasks scheduled via `$interval` use a different queue and are not flushed by
476
+ * > `$flushPendingTasks()`. Use `$interval.flush(millis)` instead.
477
+ *
478
+ * @param millis - The number of milliseconds to flush.
479
+ */
480
+ ( delay ?: number ) : void ;
481
+ }
482
+
483
+ ///////////////////////////////////////////////////////////////////////////
484
+ // VerifyNoPendingTasksService
485
+ // see https://docs.angularjs.org/api/ngMock/service/$verifyNoPendingTasks
486
+ ///////////////////////////////////////////////////////////////////////////
487
+ interface IVerifyNoPendingTasksService {
488
+ /**
489
+ * Verifies that there are no pending tasks that need to be flushed. It throws an error if there
490
+ * are still pending tasks.
491
+ *
492
+ * You can check for a specific type of tasks only, by specifying a `taskType`.
493
+ *
494
+ * Available task types:
495
+ *
496
+ * - `$timeout`: Pending timeouts (via `$timeout`).
497
+ * - `$http`: Pending HTTP requests (via `$http`).
498
+ * - `$route`: In-progress route transitions (via `$route`).
499
+ * - `$applyAsync`: Pending tasks scheduled via `$applyAsync`.
500
+ * - `$evalAsync`: Pending tasks scheduled via `$evalAsync`.
501
+ * These include tasks scheduled via `$evalAsync()` indirectly (such as `$q` promises).
502
+ *
503
+ * > Periodic tasks scheduled via `$interval` use a different queue and are not taken into
504
+ * > account by `$verifyNoPendingTasks()`. There is currently no way to verify that there are no
505
+ * > pending `$interval` tasks.
506
+ *
507
+ * @param taskType - The type of tasks to check for.
508
+ */
509
+ ( taskType ?: string ) : void ;
510
+ }
511
+
416
512
///////////////////////////////////////////////////////////////////////////
417
513
// AnimateService
418
514
// see https://docs.angularjs.org/api/ngMock/service/$animate
@@ -513,6 +609,11 @@ declare module 'angular' {
513
609
* for keyboard events (keydown, keypress, and keyup).
514
610
*/
515
611
charcode ?: number ;
612
+ /**
613
+ * [data](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent/data) for
614
+ * [CompositionEvents](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent).
615
+ */
616
+ data ?: string ;
516
617
/**
517
618
* The elapsedTime for
518
619
* [TransitionEvent](https://developer.mozilla.org/docs/Web/API/TransitionEvent)
@@ -566,10 +667,11 @@ declare global {
566
667
* This is a global (window) function that is only available when the `ngMock` module is included.
567
668
* It can be used to trigger a native browser event on an element, which is useful for unit testing.
568
669
*
569
- * @param element Either a wrapped jQuery/jqLite node or a DOM element
570
- * @param eventType Optional event type. If none is specified, the function tries to determine
571
- * the right event type for the element, e.g. `change` for `input[text]`.
572
- * @param eventData An optional object which contains additional event data used when creating the event.
670
+ * @param element Either a wrapped jQuery/jqLite node or a DOM element.
671
+ * @param eventType Optional event type. If none is specified, the function tries to determine the
672
+ * right event type for the element, e.g. `change` for `input[text]`.
673
+ * @param eventData An optional object which contains additional event data used when creating the
674
+ * event.
573
675
*/
574
676
function browserTrigger (
575
677
element : JQuery | Element ,
0 commit comments