aboutsummaryrefslogtreecommitdiffstats
path: root/src/ngMock/angular-mocks.js
diff options
context:
space:
mode:
authorIgor Minar2012-05-22 23:05:26 -0700
committerIgor Minar2012-05-23 15:00:56 -0700
commit4511d39cc748288df70bdc258f98a8f36652e683 (patch)
tree17402bb4910b12c4b1a38778309a62addd2c947f /src/ngMock/angular-mocks.js
parent15b8f205bb4e9797608ce440075e5149db6e6d45 (diff)
downloadangular.js-4511d39cc748288df70bdc258f98a8f36652e683.tar.bz2
feat($timeout): add $timeout service that supersedes $defer
$timeout has a better name ($defer got often confused with something related to $q) and is actually promise based with cancelation support. With this commit the $defer service is deprecated and will be removed before 1.0. Closes #704, #532
Diffstat (limited to 'src/ngMock/angular-mocks.js')
-rw-r--r--src/ngMock/angular-mocks.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js
index 8b5d100a..ef1833e2 100644
--- a/src/ngMock/angular-mocks.js
+++ b/src/ngMock/angular-mocks.js
@@ -1328,6 +1328,25 @@ function MockXhr() {
this.abort = angular.noop;
}
+
+/**
+ * @ngdoc function
+ * @name angular.module.ngMock.$timeout
+ * @description
+ *
+ * This service is just a simple decorator for {@link angular.module.ng.$timeout $timeout} service
+ * that adds a "flush" method.
+ */
+
+/**
+ * @ngdoc method
+ * @name angular.module.ngMock.$timeout#flush
+ * @methodOf angular.module.ngMock.$timeout
+ * @description
+ *
+ * Flushes the queue of pending tasks.
+ */
+
/**
* @ngdoc overview
* @name angular.module.ngMock
@@ -1341,6 +1360,13 @@ angular.module('ngMock', ['ng']).provider({
$exceptionHandler: angular.mock.$ExceptionHandlerProvider,
$log: angular.mock.$LogProvider,
$httpBackend: angular.mock.$HttpBackendProvider
+}).config(function($provide) {
+ $provide.decorator('$timeout', function($delegate, $browser) {
+ $delegate.flush = function() {
+ $browser.defer.flush();
+ };
+ return $delegate;
+ });
});