mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 23:34:42 +00:00
feat(ngMock.$timeout): remove flushNext method
This commit is contained in:
parent
d70711481e
commit
fc8034b352
3 changed files with 10 additions and 26 deletions
30
src/ngMock/angular-mocks.js
vendored
30
src/ngMock/angular-mocks.js
vendored
|
|
@ -75,6 +75,13 @@ angular.mock.$Browser = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ngMock.$browser#defer.now
|
||||||
|
* @propertyOf ngMock.$browser
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Current milliseconds mock time.
|
||||||
|
*/
|
||||||
self.defer.now = 0;
|
self.defer.now = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -119,29 +126,6 @@ angular.mock.$Browser = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @name ngMock.$browser#defer.flushNext
|
|
||||||
* @methodOf ngMock.$browser
|
|
||||||
*
|
|
||||||
* @description
|
|
||||||
* Flushes next pending request and compares it to the provided delay
|
|
||||||
*
|
|
||||||
* @param {number=} expectedDelay the delay value that will be asserted against the delay of the next timeout function
|
|
||||||
*/
|
|
||||||
self.defer.flushNext = function(expectedDelay) {
|
|
||||||
var tick = self.deferredFns.shift();
|
|
||||||
expect(tick.time).toEqual(expectedDelay);
|
|
||||||
tick.fn();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @name ngMock.$browser#defer.now
|
|
||||||
* @propertyOf ngMock.$browser
|
|
||||||
*
|
|
||||||
* @description
|
|
||||||
* Current milliseconds mock time.
|
|
||||||
*/
|
|
||||||
|
|
||||||
self.$$baseHref = '';
|
self.$$baseHref = '';
|
||||||
self.baseHref = function() {
|
self.baseHref = function() {
|
||||||
return this.$$baseHref;
|
return this.$$baseHref;
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ describe('$timeout', function() {
|
||||||
var promise2 = $timeout(function() {}, 100, false);
|
var promise2 = $timeout(function() {}, 100, false);
|
||||||
expect(cancelSpy).not.toHaveBeenCalled();
|
expect(cancelSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
$timeout.flushNext(0);
|
$timeout.flush(0);
|
||||||
|
|
||||||
// Promise1 deferred object should already be removed from the list and not cancellable
|
// Promise1 deferred object should already be removed from the list and not cancellable
|
||||||
$timeout.cancel(promise1);
|
$timeout.cancel(promise1);
|
||||||
|
|
|
||||||
4
test/ngMock/angular-mocksSpec.js
vendored
4
test/ngMock/angular-mocksSpec.js
vendored
|
|
@ -417,9 +417,9 @@ describe('ngMock', function() {
|
||||||
|
|
||||||
$timeout(iterate, 100);
|
$timeout(iterate, 100);
|
||||||
$timeout(iterate, 123);
|
$timeout(iterate, 123);
|
||||||
$timeout.flushNext(100);
|
$timeout.flush(100);
|
||||||
expect(count).toBe(1);
|
expect(count).toBe(1);
|
||||||
$timeout.flushNext(123);
|
$timeout.flush(123);
|
||||||
expect(count).toBe(2);
|
expect(count).toBe(2);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue