Sha256: f04550e89d64efc2ceb6427401a68cad8dbb845d492b5e08bc94d9340e1d7f9c

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

/* global self */

import { setTesting } from '@ember/debug';
import { jQuery, jQueryDisabled } from 'ember-views';
import { getAdapter, setAdapter } from './test/adapter';
import {
  incrementPendingRequests,
  decrementPendingRequests,
  clearPendingRequests,
} from './test/pending_requests';
import Adapter from './adapters/adapter';
import QUnitAdapter from './adapters/qunit';

/**
  Sets Ember up for testing. This is useful to perform
  basic setup steps in order to unit test.

  Use `App.setupForTesting` to perform integration tests (full
  application testing).

  @method setupForTesting
  @namespace Ember
  @since 1.5.0
  @private
*/
export default function setupForTesting() {
  setTesting(true);

  let adapter = getAdapter();
  // if adapter is not manually set default to QUnit
  if (!adapter) {
    setAdapter(typeof self.QUnit === 'undefined' ? new Adapter() : new QUnitAdapter());
  }

  if (!jQueryDisabled) {
    jQuery(document).off('ajaxSend', incrementPendingRequests);
    jQuery(document).off('ajaxComplete', decrementPendingRequests);

    clearPendingRequests();

    jQuery(document).on('ajaxSend', incrementPendingRequests);
    jQuery(document).on('ajaxComplete', decrementPendingRequests);
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/ember-testing/lib/setup_for_testing.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-testing/lib/setup_for_testing.js