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

Commit 2b3aad5

Browse files
committed
fixup! feat(ngMock): add $flushPendingTasks() and $verifyNoPendingTasks()
1 parent ced8cfd commit 2b3aad5

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/ngMock/angular-mocks.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ angular.mock.$Browser = function($log, $$taskTrackerFactory) {
157157
* Verifies that there are no pending tasks that need to be flushed.
158158
* You can check for a specific type of tasks only, by specifying a `taskType`.
159159
*
160-
* See {@link $verifyNoPendingsTasks} for more info.
160+
* See {@link $verifyNoPendingTasks} for more info.
161161
*
162162
* @param {string=} taskType - The type tasks to check for.
163163
*/
@@ -226,12 +226,12 @@ angular.mock.$Browser.prototype = {
226226
* The types of tasks that are flushed include:
227227
*
228228
* - Pending timeouts (via {@link $timeout}).
229-
* - Pending tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync}.
230-
* - Pending tasks scheduled via {@link ng.$rootScope.Scope#$evalAsync}.
229+
* - Pending tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync $applyAsync}.
230+
* - Pending tasks scheduled via {@link ng.$rootScope.Scope#$evalAsync $evalAsync}.
231231
* These include tasks scheduled via `$evalAsync()` indirectly (such as {@link $q} promises).
232232
*
233233
* <div class="alert alert-info">
234-
* Periodic tasks scheduled via {@link $interval} use a different queue and are flushed by
234+
* Periodic tasks scheduled via {@link $interval} use a different queue and are not flushed by
235235
* `$flushPendingTasks()`. Use {@link ngMock.$interval#flush $interval.flush([millis])} instead.
236236
* </div>
237237
*
@@ -253,21 +253,24 @@ angular.mock.$FlushPendingTasksProvider = function() {
253253
* @name $verifyNoPendingTasks
254254
*
255255
* @description
256-
* Verifies that there are no pending tasks that need to be flushed.
256+
* Verifies that there are no pending tasks that need to be flushed. It throws an error if there are
257+
* still pending tasks.
258+
*
257259
* You can check for a specific type of tasks only, by specifying a `taskType`.
258260
*
259261
* Available task types:
260262
*
261263
* - `$timeout`: Pending timeouts (via {@link $timeout}).
262264
* - `$http`: Pending HTTP requests (via {@link $http}).
263265
* - `$route`: In-progress route transitions (via {@link $route}).
264-
* - `$applyAsync`: Pending tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync}.
265-
* - `$evalAsync`: Pending tasks scheduled via {@link ng.$rootScope.Scope#$evalAsync}.
266+
* - `$applyAsync`: Pending tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync $applyAsync}.
267+
* - `$evalAsync`: Pending tasks scheduled via {@link ng.$rootScope.Scope#$evalAsync $evalAsync}.
266268
* These include tasks scheduled via `$evalAsync()` indirectly (such as {@link $q} promises).
267269
*
268270
* <div class="alert alert-info">
269271
* Periodic tasks scheduled via {@link $interval} use a different queue and are not taken into
270-
* account by `$verifyNoPendingTasks()`.
272+
* account by `$verifyNoPendingTasks()`. There is currently no way to verify that there are no
273+
* pending {@link $interval} tasks.
271274
* </div>
272275
*
273276
* @param {string=} taskType - The type of tasks to check for.
@@ -2248,12 +2251,14 @@ angular.mock.$TimeoutDecorator = ['$delegate', '$browser', function($delegate, $
22482251
* @description
22492252
*
22502253
* Flushes the queue of pending tasks.
2254+
*
22512255
* _This method is essentially an alias of {@link ngMock.$flushPendingTasks}._
22522256
*
22532257
* <div class="alert alert-warning">
22542258
* For historical reasons, this method will also flush non-`$timeout` pending tasks, such as
2255-
* {@link $q} promises and tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync} and
2256-
* {@link ng.$rootScope.Scope#$evalAsync}.
2259+
* {@link $q} promises and tasks scheduled via
2260+
* {@link ng.$rootScope.Scope#$applyAsync $applyAsync} and
2261+
* {@link ng.$rootScope.Scope#$evalAsync $evalAsync}.
22572262
* </div>
22582263
*
22592264
* @param {number=} delay maximum timeout amount to flush up until
@@ -2270,16 +2275,19 @@ angular.mock.$TimeoutDecorator = ['$delegate', '$browser', function($delegate, $
22702275
* @name $timeout#verifyNoPendingTasks
22712276
* @description
22722277
*
2273-
* Verifies that there are no pending tasks that need to be flushed.
2278+
* Verifies that there are no pending tasks that need to be flushed. It throws an error if there
2279+
* are still pending tasks.
2280+
*
22742281
* _This method is essentially an alias of {@link ngMock.$verifyNoPendingTasks} (called with no
22752282
* arguments)._
22762283
*
22772284
* <div class="alert alert-warning">
22782285
* <p>
22792286
* For historical reasons, this method will also verify non-`$timeout` pending tasks, such as
22802287
* pending {@link $http} requests, in-progress {@link $route} transitions, unresolved
2281-
* {@link $q} promises and tasks scheduled via {@link ng.$rootScope.Scope#$applyAsync} and
2282-
* {@link ng.$rootScope.Scope#$evalAsync}.
2288+
* {@link $q} promises and tasks scheduled via
2289+
* {@link ng.$rootScope.Scope#$applyAsync $applyAsync} and
2290+
* {@link ng.$rootScope.Scope#$evalAsync $evalAsync}.
22832291
* </p>
22842292
* <p>
22852293
* It is recommended to use {@link ngMock.$verifyNoPendingTasks} instead, which additionally

0 commit comments

Comments
 (0)