<commit_before>import { run } from '@ember/runloop';
import { set, setProperties, get, getProperties } from '@ember/object';
import { guidFor } from '@ember/object/internals';
import buildOwner from './build-owner';
import { _setupPromiseListeners } from './ext/rsvp';
import { _setupAJAXHooks } from './settled';
import Ember from 'ember';
import { Promise } from 'rsvp';
import { assert } from '@ember/debug';
import global from './global';
import { getResolver } from './resolver';
import { getApplication } from './application';
import { nextTickPromise } from './-utils';

let __test_context__;

/**
  Stores the provided context as the "global testing context".

  Generally setup automatically by `setupContext`.

  @public
  @param {Object} context the context to use
*/
export function setContext(context) {
  __test_context__ = context;
}

/**
  Retrive the "global testing context" as stored by `setContext`.

  @public
  @returns {Object} the previously stored testing context
*/
export function getContext() {
  return __test_context__;
}

/**
  Clear the "global testing context".

  Generally invoked from `teardownContext`.

  @public
*/
export function unsetContext() {
  __test_context__ = undefined;
}

/**
  Returns a promise to be used to pauses the current test (due to being
  returned from the test itself).  This is useful for debugging while testing
  or for test-driving.  It allows you to inspect the state of your application
  at any point.

  @example <caption>Usage via ember-qunit</caption>

  ```js
  import { setupRenderingTest } from 'ember-qunit';
  import { render, click, pauseTest } from '@ember/test-helpers';

  module('awesome-sauce', function(hooks) {
    setupRenderingTest(hooks);

    test('does something awesome', function(assert) {
      render(hbs`{{awesome-sauce}}`);

      // added here to visualize / interact with the DOM prior
      // to the interaction below
      return pauseTest();

      click('.some-selector');

      assert.equal(this.element.textContent, 'this sauce is awesome!');
    });
  });
  ```

  @public
  @returns {Promise<void>} resolves _only_ when `resumeTest()` is invoked
*/
export function pauseTest() {
  let context = getContext();

  if (!context || typeof context.pauseTest !== 'function') {
    throw new Error(
      'Cannot call `pauseTest` without having first called `setupTest` or `setupRenderingTest`.'
    );
  }

  return context.pauseTest();
}

/**
  Resumes a test previously paused by `return pauseTest()`.

  @public
*/
export function resumeTest() {
  let context = getContext();

  if (!context || typeof context.resumeTest !== 'function') {
    throw new Error(
      'Cannot call `resumeTest` without having first called `setupTest` or `setupRenderingTest`.'
    );
  }

  context.resumeTest();
}

export const CLEANUP = Object.create(null);

/**
  Used by test framework addons to setup the provided context for testing.

  Responsible for:<commit_msg>Docs: use async/await in pauseTest example<commit_after>import { run } from '@ember/runloop';
import { set, setProperties, get, getProperties } from '@ember/object';
import { guidFor } from '@ember/object/internals';
import buildOwner from './build-owner';
import { _setupPromiseListeners } from './ext/rsvp';
import { _setupAJAXHooks } from './settled';
import Ember from 'ember';
import { Promise } from 'rsvp';
import { assert } from '@ember/debug';
import global from './global';
import { getResolver } from './resolver';
import { getApplication } from './application';
import { nextTickPromise } from './-utils';

let __test_context__;

/**
  Stores the provided context as the "global testing context".

  Generally setup automatically by `setupContext`.

  @public
  @param {Object} context the context to use
*/
export function setContext(context) {
  __test_context__ = context;
}

/**
  Retrive the "global testing context" as stored by `setContext`.

  @public
  @returns {Object} the previously stored testing context
*/
export function getContext() {
  return __test_context__;
}

/**
  Clear the "global testing context".

  Generally invoked from `teardownContext`.

  @public
*/
export function unsetContext() {
  __test_context__ = undefined;
}

/**
 * Returns a promise to be used to pauses the current test (due to being
 * returned from the test itself).  This is useful for debugging while testing
 * or for test-driving.  It allows you to inspect the state of your application
 * at any point.
 *
 * The test framework wrapper (e.g. `ember-qunit` or `ember-mocha`) should
 * ensure that when `pauseTest()` is used, any framework specific test timeouts
 * are disabled.
 *
 * @public
 * @returns {Promise<void>} resolves _only_ when `resumeTest()` is invoked
 * @example <caption>Usage via ember-qunit</caption>
 *
 * import { setupRenderingTest } from 'ember-qunit';
 * import { render, click, pauseTest } from '@ember/test-helpers';
 *
 *
 * module('awesome-sauce', function(hooks) {
 *   setupRenderingTest(hooks);
 *
 *   test('does something awesome', async function(assert) {
 *     await render(hbs`{{awesome-sauce}}`);
 *
 *     // added here to visualize / interact with the DOM prior
 *     // to the interaction below
 *     await pauseTest();
 *
 *     click('.some-selector');
 *
 *     assert.equal(this.element.textContent, 'this sauce is awesome!');
 *   });
 * });
 */
export function pauseTest() {
  let context = getContext();

  if (!context || typeof context.pauseTest !== 'function') {
    throw new Error(
      'Cannot call `pauseTest` without having first called `setupTest` or `setupRenderingTest`.'
    );
  }

  return context.pauseTest();
}

/**
  Resumes a test previously paused by `await pauseTest()`.

  @public
*/
export function resumeTest() {
  let context = getContext();

  if (!context || typeof context.resumeTest !== 'function') {
    throw new Error(
      'Cannot call `resumeTest` without having first called `setupTest` or `setupRenderingTest`.'
    );
  }

  context.resumeTest();
}

export const CLEANUP = Object.create(null);

/**
  Used by test framework addons to setup the provided context for testing.

  Responsible for:
{'fraction_non_alphanumeric': 0.12225654365143879, 'fraction_numerical': 0.0, 'mean_word_length': 3.8555643251775846, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7317022', 'n_tokens_mistral': 1767, 'n_tokens_neox': 1751, 'n_words': 619}