Re-refactored Queue to use straightforward callbacks

This commit is contained in:
ragaskar
2009-08-03 22:22:13 -07:00
parent 9475de28b3
commit 0d6c6c2a35
8 changed files with 47 additions and 72 deletions

View File

@@ -10,7 +10,7 @@ jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100;
jasmine.WaitsForBlock.prototype.execute = function () {
jasmine.WaitsForBlock.prototype.execute = function (onComplete) {
var self = this;
self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen'));
var latchFunctionResult;
@@ -18,12 +18,12 @@ jasmine.WaitsForBlock.prototype.execute = function () {
latchFunctionResult = self.latchFunction.apply(self.spec);
} catch (e) {
self.fail(e);
self._next();
onComplete();
return;
}
if (latchFunctionResult) {
self._next();
onComplete();
} else if (self.totalTimeSpentWaitingForLatch >= self.timeout) {
var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen');
self.fail({
@@ -33,6 +33,6 @@ jasmine.WaitsForBlock.prototype.execute = function () {
self.spec._next();
} else {
self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
self.env.setTimeout(function () { self.execute(); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
}
};