From 59fdefd70ebd443ecd429d2c8e6986698ae2d2e7 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 21 Apr 2020 10:31:42 -0400 Subject: [PATCH] Remove `ember-test-helpers/wait`. This was replaced by `settled`. --- addon-test-support/ember-test-helpers/wait.js | 51 ------------------- .../test-module-for-component-test.js | 5 +- tests/unit/wait-test.js | 12 ----- 3 files changed, 2 insertions(+), 66 deletions(-) delete mode 100644 addon-test-support/ember-test-helpers/wait.js delete mode 100644 tests/unit/wait-test.js diff --git a/addon-test-support/ember-test-helpers/wait.js b/addon-test-support/ember-test-helpers/wait.js deleted file mode 100644 index 1652c17f1..000000000 --- a/addon-test-support/ember-test-helpers/wait.js +++ /dev/null @@ -1,51 +0,0 @@ -export { _setupAJAXHooks, _teardownAJAXHooks } from '@ember/test-helpers/settled'; - -import { waitUntil, getSettledState } from '@ember/test-helpers'; - -/** - Returns a promise that resolves when in a settled state (see `isSettled` for - a definition of "settled state"). - - @private - @deprecated - @param {Object} [options={}] the options to be used for waiting - @param {boolean} [options.waitForTimers=true] should timers be waited upon - @param {boolean} [options.waitForAjax=true] should $.ajax requests be waited upon - @param {boolean} [options.waitForWaiters=true] should test waiters be waited upon - @returns {Promise} resolves when settled -*/ -export default function wait(options = {}) { - if (typeof options !== 'object' || options === null) { - options = {}; - } - - return waitUntil( - () => { - let waitForTimers = 'waitForTimers' in options ? options.waitForTimers : true; - let waitForAJAX = 'waitForAJAX' in options ? options.waitForAJAX : true; - let waitForWaiters = 'waitForWaiters' in options ? options.waitForWaiters : true; - - let { - hasPendingTimers, - hasRunLoop, - hasPendingRequests, - hasPendingWaiters, - } = getSettledState(); - - if (waitForTimers && (hasPendingTimers || hasRunLoop)) { - return false; - } - - if (waitForAJAX && hasPendingRequests) { - return false; - } - - if (waitForWaiters && hasPendingWaiters) { - return false; - } - - return true; - }, - { timeout: Infinity } - ); -} diff --git a/tests/unit/legacy-0-6-x/test-module-for-component-test.js b/tests/unit/legacy-0-6-x/test-module-for-component-test.js index e1397f19c..455684a19 100644 --- a/tests/unit/legacy-0-6-x/test-module-for-component-test.js +++ b/tests/unit/legacy-0-6-x/test-module-for-component-test.js @@ -12,11 +12,10 @@ import Ember from 'ember'; import { TestModuleForComponent } from 'ember-test-helpers'; import hasEmberVersion from 'ember-test-helpers/has-ember-version'; import { setResolverRegistry } from '../../helpers/resolver'; -import wait from 'ember-test-helpers/wait'; import qunitModuleFor from '../../helpers/qunit-module-for'; import hasjQuery from '../../helpers/has-jquery'; import hbs from 'htmlbars-inline-precompile'; -import { triggerEvent, focus, blur } from '@ember/test-helpers'; +import { settled, triggerEvent, focus, blur } from '@ember/test-helpers'; import { htmlSafe } from '@ember/string'; var Service = EmberService || EmberObject; @@ -854,7 +853,7 @@ test('does not require manual run wrapping', function (assert) { return new resolve() .then(() => { instance.set('internalValue', 'async value'); - return wait(); + return settled(); }) .then(() => { assert.equal(this._element.textContent, 'async value'); diff --git a/tests/unit/wait-test.js b/tests/unit/wait-test.js deleted file mode 100644 index e2cf9a6b9..000000000 --- a/tests/unit/wait-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { module, test } from 'qunit'; -import wait from 'ember-test-helpers/wait'; - -module('wait: unit tests', function () { - test('issues a helpful assertion for invalid arguments', async function (assert) { - assert.expect(0); // no assertions, just shouldn't error - - await wait(3000); - await wait(null); - await wait(); - }); -});