Пример #1
0
run.scheduleOnce = function(/*queue, target, method*/) {
  assert(
    `You have turned on testing mode, which disabled the run-loop's autorun. ` +
    `You will need to wrap any code with asynchronous side-effects in a run`,
    run.currentRunLoop || !isTesting()
  );
  return backburner.scheduleOnce(...arguments);
};
Пример #2
0
run.once = function(...args) {
  assert(
    `You have turned on testing mode, which disabled the run-loop's autorun. ` +
    `You will need to wrap any code with asynchronous side-effects in a run`,
    run.currentRunLoop || !isTesting()
  );
  args.unshift('actions');
  return backburner.scheduleOnce(...args);
};
Пример #3
0
QUnit.test('rejections can be serialized to JSON', function (assert) {
  expect(2);

  let wasEmberTesting = isTesting();
  let wasOnError      = getOnerror();

  try {
    setTesting(false);
    setOnerror(error => {
      assert.equal(error.message, 'a fail');
      assert.ok(JSON.stringify(error), 'Error can be serialized');
    });

    let jqXHR = {
      errorThrown: new Error('a fail')
    };

    run(RSVP, 'reject', jqXHR);
  } finally {
    setOnerror(wasOnError);
    setTesting(wasEmberTesting);
  }
});
Пример #4
0
QUnit.test('rejections where the errorThrown is a string should wrap the sting in an error object', function() {
  expect(2);

  let wasEmberTesting = isTesting();
  let wasOnError      = getOnerror();

  try {
    setTesting(false);
    setOnerror(error => {
      equal(error.message, actualError, 'expected the real error on the jqXHR');
      equal(error.__reason_with_error_thrown__, jqXHR, 'also retains a helpful reference to the rejection reason');
    });

    let actualError = 'OMG what really happened';
    let jqXHR = {
      errorThrown: actualError
    };

    run(RSVP, 'reject', jqXHR);
  } finally {
    setOnerror(wasOnError);
    setTesting(wasEmberTesting);
  }
});
Пример #5
0
QUnit.test('rejections like jqXHR which have errorThrown property work', function() {
  expect(2);

  let wasEmberTesting = isTesting();
  let wasOnError      = getOnerror();

  try {
    setTesting(false);
    setOnerror(error => {
      equal(error, actualError, 'expected the real error on the jqXHR');
      equal(error.__reason_with_error_thrown__, jqXHR, 'also retains a helpful reference to the rejection reason');
    });

    let actualError = new Error('OMG what really happened');
    let jqXHR = {
      errorThrown: actualError
    };

    run(RSVP, 'reject', jqXHR);
  } finally {
    setOnerror(wasOnError);
    setTesting(wasEmberTesting);
  }
});
Пример #6
0
      run(instance, 'destroy');
      this._buildDeprecatedInstance();
      run.schedule('actions', this, '_bootSync');
    }

    run.join(this, handleReset);
  },

  /**
    @private
    @method didBecomeReady
  */
  didBecomeReady() {
    try {
      // TODO: Is this still needed for _globalsMode = false?
      if (!isTesting()) {
        // Eagerly name all classes that are already loaded
        Namespace.processAll();
        setNamespaceSearchDisabled(true);
      }

      // See documentation on `_autoboot()` for details
      if (this.autoboot) {
        let instance;

        if (this._globalsMode) {
          // If we already have the __deprecatedInstance__ lying around, boot it to
          // avoid unnecessary work
          instance = this.__deprecatedInstance__;
        } else {
          // Otherwise, build an instance and boot it. This is currently unreachable,