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