@@ -1114,11 +1114,12 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
|||||||
|
|
||||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||||
var funcToRun = funcsToRun[i];
|
var funcToRun = funcsToRun[i];
|
||||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
|
||||||
|
|
||||||
if (funcToRun.recurring) {
|
if (funcToRun.recurring) {
|
||||||
reschedule(funcToRun);
|
reschedule(funcToRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
||||||
}
|
}
|
||||||
} while (scheduledLookup.length > 0 &&
|
} while (scheduledLookup.length > 0 &&
|
||||||
// checking first if we're out of time prevents setTimeout(0)
|
// checking first if we're out of time prevents setTimeout(0)
|
||||||
|
|||||||
@@ -323,6 +323,24 @@ describe("Clock (acceptance)", function() {
|
|||||||
expect(clearedFn).not.toHaveBeenCalled();
|
expect(clearedFn).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("can clear a previously set interval using that interval's handler", function() {
|
||||||
|
var spy = jasmine.createSpy('spy'),
|
||||||
|
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
||||||
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
||||||
|
clock = new j$.Clock({setInterval: function() {}}, delayedFunctionScheduler, mockDate),
|
||||||
|
intervalId;
|
||||||
|
|
||||||
|
clock.install();
|
||||||
|
|
||||||
|
intervalId = clock.setInterval(function() {
|
||||||
|
spy();
|
||||||
|
clock.clearInterval(intervalId);
|
||||||
|
}, 100);
|
||||||
|
clock.tick(200);
|
||||||
|
|
||||||
|
expect(spy.calls.count()).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
it("correctly schedules functions after the Clock has advanced", function() {
|
it("correctly schedules functions after the Clock has advanced", function() {
|
||||||
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||||
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
||||||
|
|||||||
@@ -242,5 +242,18 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
expect(innerFn).toHaveBeenCalled();
|
expect(innerFn).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("executes recurring functions after rescheduling them", function () {
|
||||||
|
var scheduler = new j$.DelayedFunctionScheduler(),
|
||||||
|
recurring = function() {
|
||||||
|
expect(scheduler.scheduleFunction).toHaveBeenCalled();
|
||||||
|
};
|
||||||
|
|
||||||
|
scheduler.scheduleFunction(recurring, 10, [], true);
|
||||||
|
|
||||||
|
spyOn(scheduler, "scheduleFunction");
|
||||||
|
|
||||||
|
scheduler.tick(10);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -127,11 +127,12 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
|||||||
|
|
||||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||||
var funcToRun = funcsToRun[i];
|
var funcToRun = funcsToRun[i];
|
||||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
|
||||||
|
|
||||||
if (funcToRun.recurring) {
|
if (funcToRun.recurring) {
|
||||||
reschedule(funcToRun);
|
reschedule(funcToRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
||||||
}
|
}
|
||||||
} while (scheduledLookup.length > 0 &&
|
} while (scheduledLookup.length > 0 &&
|
||||||
// checking first if we're out of time prevents setTimeout(0)
|
// checking first if we're out of time prevents setTimeout(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user