Sha256: eadb861138ce0c625483bfd1b4fac2ad6bc19fbc10d1abf7d3098b56b12f8ca8

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
  this.timeout = timeout;
  this.latchFunction = latchFunction;
  this.message = message;
  this.totalTimeSpentWaitingForLatch = 0;
  jasmine.Block.call(this, env, null, spec);
};

jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);

jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100;

jasmine.WaitsForBlock.prototype.execute = function (onComplete) {
  var self = this;
  self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen'));
  var latchFunctionResult;
  try {
    latchFunctionResult = self.latchFunction.apply(self.spec);
  } catch (e) {
    self.spec.fail(e);
    onComplete();
    return;
  }

  if (latchFunctionResult) {
    onComplete();
  } else if (self.totalTimeSpentWaitingForLatch >= self.timeout) {
    var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen');
    self.spec.fail({
      name: 'timeout',
      message: message
    });
    self.spec._next();
  } else {
    self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
    self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
  }
};

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
jasnode-0.4.3.0 jasmine/src/WaitsForBlock.js
jasnode-0.4.2.0 jasmine/src/WaitsForBlock.js
jasnode-0.4.1.0 jasmine/src/WaitsForBlock.js
jasnode-0.4.0.0 jasmine/src/WaitsForBlock.js
jasnode-0.2.0.0 jasmine/src/WaitsForBlock.js
jazz-0.1.1 vendor/jasmine/src/WaitsForBlock.js
jazrb-0.1.1 vendor/jasmine/src/WaitsForBlock.js
jazrb-0.1.0 vendor/jasmine/src/WaitsForBlock.js