mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
feat(ngMock.$timeout): remove flushNext method
This commit is contained in:
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;
|
||||
|
||||
|
||||
@@ -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 = function() {
|
||||
return this.$$baseHref;
|
||||
|
||||
@@ -77,7 +77,7 @@ describe('$timeout', function() {
|
||||
var promise2 = $timeout(function() {}, 100, false);
|
||||
expect(cancelSpy).not.toHaveBeenCalled();
|
||||
|
||||
$timeout.flushNext(0);
|
||||
$timeout.flush(0);
|
||||
|
||||
// Promise1 deferred object should already be removed from the list and not cancellable
|
||||
$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, 123);
|
||||
$timeout.flushNext(100);
|
||||
$timeout.flush(100);
|
||||
expect(count).toBe(1);
|
||||
$timeout.flushNext(123);
|
||||
$timeout.flush(123);
|
||||
expect(count).toBe(2);
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user