Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 3c7e596

Browse files
committed
fixup! feat(ngMock): add $flushPendingTasks() and $verifyNoPendingTasks()
1 parent 012621a commit 3c7e596

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/ngMock/angular-mocks.js

+21-13
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ angular.mock.$Browser = function($log, $$taskTrackerFactory) {
187187
* Verifies that there are no pending tasks that need to be flushed.
188188
* You can check for a specific type of tasks only, by specifying a `taskType`.
189189
*
190-
* See {@link $verifyNoPendingsTasks} for more info.
190+
* See {@link $verifyNoPendingTasks} for more info.
191191
*
192192
* @param {string=} taskType - The type tasks to check for.
193193
*/
@@ -249,12 +249,12 @@ angular.mock.$Browser.prototype = {
249249
* The types of tasks that are flushed include:
250250
*
251251
* - Pending timeouts (via {@link $timeout}).
252-
* - Pending tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync}.
253-
* - Pending tasks scheduled via {@link ng.$rootScope.Scope#$evalAsync}.
252+
* - Pending tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync $applyAsync}.
253+
* - Pending tasks scheduled via {@link ng.$rootScope.Scope#$evalAsync $evalAsync}.
254254
* These include tasks scheduled via `$evalAsync()` indirectly (such as {@link $q} promises).
255255
*
256256
* <div class="alert alert-info">
257-
* Periodic tasks scheduled via {@link $interval} use a different queue and are flushed by
257+
* Periodic tasks scheduled via {@link $interval} use a different queue and are not flushed by
258258
* `$flushPendingTasks()`. Use {@link ngMock.$interval#flush $interval.flush([millis])} instead.
259259
* </div>
260260
*
@@ -276,21 +276,24 @@ angular.mock.$FlushPendingTasksProvider = function() {
276276
* @name $verifyNoPendingTasks
277277
*
278278
* @description
279-
* Verifies that there are no pending tasks that need to be flushed.
279+
* Verifies that there are no pending tasks that need to be flushed. It throws an error if there are
280+
* still pending tasks.
281+
*
280282
* You can check for a specific type of tasks only, by specifying a `taskType`.
281283
*
282284
* Available task types:
283285
*
284286
* - `$timeout`: Pending timeouts (via {@link $timeout}).
285287
* - `$http`: Pending HTTP requests (via {@link $http}).
286288
* - `$route`: In-progress route transitions (via {@link $route}).
287-
* - `$applyAsync`: Pending tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync}.
288-
* - `$evalAsync`: Pending tasks scheduled via {@link ng.$rootScope.Scope#$evalAsync}.
289+
* - `$applyAsync`: Pending tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync $applyAsync}.
290+
* - `$evalAsync`: Pending tasks scheduled via {@link ng.$rootScope.Scope#$evalAsync $evalAsync}.
289291
* These include tasks scheduled via `$evalAsync()` indirectly (such as {@link $q} promises).
290292
*
291293
* <div class="alert alert-info">
292294
* Periodic tasks scheduled via {@link $interval} use a different queue and are not taken into
293-
* account by `$verifyNoPendingTasks()`.
295+
* account by `$verifyNoPendingTasks()`. There is currently no way to verify that there are no
296+
* pending {@link $interval} tasks.
294297
* </div>
295298
*
296299
* @param {string=} taskType - The type of tasks to check for.
@@ -2278,12 +2281,14 @@ angular.mock.$TimeoutDecorator = ['$delegate', '$browser', function($delegate, $
22782281
* @description
22792282
*
22802283
* Flushes the queue of pending tasks.
2284+
*
22812285
* _This method is essentially an alias of {@link ngMock.$flushPendingTasks}._
22822286
*
22832287
* <div class="alert alert-warning">
22842288
* For historical reasons, this method will also flush non-`$timeout` pending tasks, such as
2285-
* {@link $q} promises and tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync} and
2286-
* {@link ng.$rootScope.Scope#$evalAsync}.
2289+
* {@link $q} promises and tasks scheduled via
2290+
* {@link ng.$rootScope.Scope#$applyAsync $applyAsync} and
2291+
* {@link ng.$rootScope.Scope#$evalAsync $evalAsync}.
22872292
* </div>
22882293
*
22892294
* @param {number=} delay maximum timeout amount to flush up until
@@ -2308,16 +2313,19 @@ angular.mock.$TimeoutDecorator = ['$delegate', '$browser', function($delegate, $
23082313
*
23092314
* @description
23102315
*
2311-
* Verifies that there are no pending tasks that need to be flushed.
2316+
* Verifies that there are no pending tasks that need to be flushed. It throws an error if there
2317+
* are still pending tasks.
2318+
*
23122319
* _This method is essentially an alias of {@link ngMock.$verifyNoPendingTasks} (called with no
23132320
* arguments)._
23142321
*
23152322
* <div class="alert alert-warning">
23162323
* <p>
23172324
* For historical reasons, this method will also verify non-`$timeout` pending tasks, such as
23182325
* pending {@link $http} requests, in-progress {@link $route} transitions, unresolved
2319-
* {@link $q} promises and tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync} and
2320-
* {@link ng.$rootScope.Scope#$evalAsync}.
2326+
* {@link $q} promises and tasks scheduled via
2327+
* {@link ng.$rootScope.Scope#$applyAsync $applyAsync} and
2328+
* {@link ng.$rootScope.Scope#$evalAsync $evalAsync}.
23212329
* </p>
23222330
* <p>
23232331
* It is recommended to use {@link ngMock.$verifyNoPendingTasks} instead, which additionally

0 commit comments

Comments
 (0)