Clear timeouts when starting to process a milli instead of at the end
- Fixes #1482
This commit is contained in:
@@ -254,6 +254,22 @@ describe("DelayedFunctionScheduler", function() {
|
||||
expect(fn.calls.count()).toBe(1);
|
||||
});
|
||||
|
||||
it("does not remove a function that hasn't been added yet", function() {
|
||||
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10,
|
||||
timeoutKey;
|
||||
|
||||
scheduler.removeFunctionWithId('foo');
|
||||
scheduler.scheduleFunction(fn, fnDelay, [], false, 'foo');
|
||||
|
||||
expect(fn).not.toHaveBeenCalled();
|
||||
|
||||
scheduler.tick(fnDelay + 1);
|
||||
|
||||
expect(fn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("updates the mockDate per scheduled time", function () {
|
||||
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
tickDate = jasmine.createSpy('tickDate');
|
||||
|
||||
@@ -124,6 +124,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
||||
}
|
||||
|
||||
do {
|
||||
deletedKeys = [];
|
||||
var newCurrentTime = scheduledLookup.shift();
|
||||
tickDate(newCurrentTime - currentTime);
|
||||
|
||||
@@ -146,7 +147,6 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
||||
}
|
||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
||||
});
|
||||
deletedKeys = [];
|
||||
} while (scheduledLookup.length > 0 &&
|
||||
// checking first if we're out of time prevents setTimeout(0)
|
||||
// scheduled in a funcToRun from forcing an extra iteration
|
||||
|
||||
Reference in New Issue
Block a user