aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngMock/angular-mocksSpec.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 /test/ngMock/angular-mocksSpec.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 'test/ngMock/angular-mocksSpec.js')
-rw-r--r--test/ngMock/angular-mocksSpec.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js
index 469df91e..62190072 100644
--- a/test/ngMock/angular-mocksSpec.js
+++ b/test/ngMock/angular-mocksSpec.js
@@ -313,6 +313,23 @@ describe('ngMock', function() {
});
+ describe('$timeout', function() {
+ it('should expose flush method that will flush the pending queue of tasks', inject(
+ function($timeout) {
+ var logger = [],
+ logFn = function(msg) { return function() { logger.push(msg) }};
+
+ $timeout(logFn('t1'));
+ $timeout(logFn('t2'), 200);
+ $timeout(logFn('t3'));
+ expect(logger).toEqual([]);
+
+ $timeout.flush();
+ expect(logger).toEqual(['t1', 't3', 't2']);
+ }));
+ });
+
+
describe('angular.mock.dump', function(){
var d = angular.mock.dump;