mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
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
This commit is contained in:
17
test/ngMock/angular-mocksSpec.js
vendored
17
test/ngMock/angular-mocksSpec.js
vendored
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user