Improve this Doc View Source $timeout

From Get docs
< Improve this Doc ngMock‎ | serviceAngularjs/docs/1.8/api/ngmock/service/$timeout


Improve this Doc View Source $timeout

  1. service in module ngMock

Overview

This service is just a simple decorator for $timeout service that adds a "flush" and "verifyNoPendingTasks" methods.


Methods

  • === flush([delay]); ===

    Flushes the queue of pending tasks.

    This method is essentially an alias of $flushPendingTasks.

    For historical reasons, this method will also flush non-$timeout pending tasks, such as $q promises and tasks scheduled via $applyAsync and $evalAsync.

    Deprecated: (since 1.7.3)

    This method flushes all types of tasks (not only timeouts), which is unintuitive. It is recommended to use $flushPendingTasks instead.

    Parameters

    Param Type Details

    delay

    (optional)

    number

    maximum timeout amount to flush up until

  • === verifyNoPendingTasks(); ===

    Verifies that there are no pending tasks that need to be flushed. It throws an error if there are still pending tasks.

    This method is essentially an alias of $verifyNoPendingTasks (called with no arguments).

    For historical reasons, this method will also verify non-$timeout pending tasks, such as pending $http requests, in-progress $route transitions, unresolved $q promises and tasks scheduled via $applyAsync and $evalAsync.

    It is recommended to use $verifyNoPendingTasks instead, which additionally supports verifying a specific type of tasks. For example, you can verify there are no pending timeouts with $verifyNoPendingTasks('$timeout').

    Deprecated: (since 1.7.3)

    This method takes all types of tasks (not only timeouts) into account, which is unintuitive. It is recommended to use $verifyNoPendingTasks instead, which additionally allows checking for timeouts only (with $verifyNoPendingTasks('$timeout')).


© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.
https://code.angularjs.org/1.8.2/docs/api/ngMock/service/$timeout