Merge branch 'tgirardi-issue655'

Fix #655 #658
This commit is contained in:
slackersoft
2014-09-02 13:19:44 -07:00
4 changed files with 35 additions and 2 deletions

View File

@@ -1114,11 +1114,12 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
for (var i = 0; i < funcsToRun.length; ++i) {
var funcToRun = funcsToRun[i];
funcToRun.funcToCall.apply(null, funcToRun.params || []);
if (funcToRun.recurring) {
reschedule(funcToRun);
}
funcToRun.funcToCall.apply(null, funcToRun.params || []);
}
} while (scheduledLookup.length > 0 &&
// checking first if we're out of time prevents setTimeout(0)

View File

@@ -323,6 +323,24 @@ describe("Clock (acceptance)", function() {
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() {
var delayedFn1 = jasmine.createSpy('delayedFn1'),
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),

View File

@@ -242,5 +242,18 @@ describe("DelayedFunctionScheduler", function() {
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);
});
});

View File

@@ -127,11 +127,12 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
for (var i = 0; i < funcsToRun.length; ++i) {
var funcToRun = funcsToRun[i];
funcToRun.funcToCall.apply(null, funcToRun.params || []);
if (funcToRun.recurring) {
reschedule(funcToRun);
}
funcToRun.funcToCall.apply(null, funcToRun.params || []);
}
} while (scheduledLookup.length > 0 &&
// checking first if we're out of time prevents setTimeout(0)