Only clear stack when QueueRunner is done with its functions
This commit is contained in:
@@ -1311,9 +1311,8 @@ getJasmineRequireObj().QueueRunner = function() {
|
||||
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
||||
var fn = fns[iterativeIndex];
|
||||
if (fn.length > 0) {
|
||||
attempt(function() { fn.call(self, function() {
|
||||
self.clearStack(function() { self.run(fns, iterativeIndex + 1); });
|
||||
});
|
||||
attempt(function() {
|
||||
fn.call(self, function() { self.run(fns, iterativeIndex + 1); });
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
@@ -1321,7 +1320,12 @@ getJasmineRequireObj().QueueRunner = function() {
|
||||
}
|
||||
}
|
||||
|
||||
if (iterativeIndex >= length) {
|
||||
var runnerDone = iterativeIndex >= length,
|
||||
hasBeenAsyncSpec = recursiveIndex > 0;
|
||||
|
||||
if (runnerDone && hasBeenAsyncSpec) {
|
||||
this.clearStack(this.onComplete);
|
||||
} else if(runnerDone) {
|
||||
this.onComplete();
|
||||
}
|
||||
|
||||
|
||||
@@ -115,21 +115,19 @@ describe("QueueRunner", function() {
|
||||
expect(completeCallback).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls a provided stack clearing function when done with async specs", function() {
|
||||
var fn = function(done) { done() },
|
||||
completeCallback = jasmine.createSpy('completeCallback'),
|
||||
clearStack = jasmine.createSpy('clearStack'),
|
||||
queueRunner = new j$.QueueRunner({
|
||||
fns: [fn],
|
||||
clearStack: clearStack,
|
||||
onComplete: completeCallback
|
||||
});
|
||||
|
||||
clearStack.andCallFake(function(fn) { fn(); });
|
||||
it("with an async spec, calls a provided stack clearing function when done", function() {
|
||||
var asyncFn = function(done) { done() },
|
||||
afterFn = jasmine.createSpy('afterFn'),
|
||||
completeCallback = jasmine.createSpy('completeCallback'),
|
||||
clearStack = jasmine.createSpy('clearStack'),
|
||||
queueRunner = new j$.QueueRunner({
|
||||
fns: [asyncFn, afterFn],
|
||||
clearStack: clearStack,
|
||||
onComplete: completeCallback
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
|
||||
expect(clearStack).toHaveBeenCalled();
|
||||
expect(completeCallback).toHaveBeenCalled();
|
||||
expect(afterFn).toHaveBeenCalled();
|
||||
expect(clearStack).toHaveBeenCalledWith(completeCallback);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,9 +20,8 @@ getJasmineRequireObj().QueueRunner = function() {
|
||||
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
||||
var fn = fns[iterativeIndex];
|
||||
if (fn.length > 0) {
|
||||
attempt(function() { fn.call(self, function() {
|
||||
self.clearStack(function() { self.run(fns, iterativeIndex + 1); });
|
||||
});
|
||||
attempt(function() {
|
||||
fn.call(self, function() { self.run(fns, iterativeIndex + 1); });
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
@@ -30,7 +29,12 @@ getJasmineRequireObj().QueueRunner = function() {
|
||||
}
|
||||
}
|
||||
|
||||
if (iterativeIndex >= length) {
|
||||
var runnerDone = iterativeIndex >= length,
|
||||
hasBeenAsyncSpec = recursiveIndex > 0;
|
||||
|
||||
if (runnerDone && hasBeenAsyncSpec) {
|
||||
this.clearStack(this.onComplete);
|
||||
} else if(runnerDone) {
|
||||
this.onComplete();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user