From 4511d39cc748288df70bdc258f98a8f36652e683 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 22 May 2012 23:05:26 -0700 Subject: 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 --- src/ngMock/angular-mocks.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/ngMock') 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; + }); }); -- cgit v1.2.3