From c0f19566dd89e3be00a291d8ba6b2f0a3ec1a85e Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 11 Jan 2018 11:06:18 -0500 Subject: [PATCH] Remove unused testing helper files. As of ember-source@3.0.0 (and ember-data@3.0.0) the testing blueprints are automatically emitting emberjs/rfcs#232 or emberjs/rfcs#268 compatible output. With those, these helpers are no longer used for new apps. Existing apps should only delete these files once they have migrated to the new testing system... --- blueprints/app/files/tests/helpers/.gitkeep | 0 .../app/files/tests/helpers/destroy-app.js | 5 --- .../tests/helpers/module-for-acceptance.js | 21 ------------ .../app/files/tests/helpers/start-app.js | 17 ---------- .../files/tests/helpers/.gitkeep | 0 .../files/tests/helpers/destroy-app.js | 5 --- .../tests/helpers/module-for-acceptance.js | 21 ------------ .../files/tests/helpers/start-app.js | 16 --------- .../tests/acceptance/main-test.js | 34 +++++++------------ .../tests/acceptance/main-test.js | 34 +++++++------------ .../tests/integration/app-boots-test.js | 24 +++++-------- .../tests/integration/pods-template-test.js | 24 +++++-------- .../tests/integration/pods-template-test.js | 25 +++++--------- 13 files changed, 52 insertions(+), 174 deletions(-) create mode 100644 blueprints/app/files/tests/helpers/.gitkeep delete mode 100644 blueprints/app/files/tests/helpers/destroy-app.js delete mode 100644 blueprints/app/files/tests/helpers/module-for-acceptance.js delete mode 100644 blueprints/app/files/tests/helpers/start-app.js create mode 100644 blueprints/module-unification-app/files/tests/helpers/.gitkeep delete mode 100644 blueprints/module-unification-app/files/tests/helpers/destroy-app.js delete mode 100644 blueprints/module-unification-app/files/tests/helpers/module-for-acceptance.js delete mode 100644 blueprints/module-unification-app/files/tests/helpers/start-app.js diff --git a/blueprints/app/files/tests/helpers/.gitkeep b/blueprints/app/files/tests/helpers/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/blueprints/app/files/tests/helpers/destroy-app.js b/blueprints/app/files/tests/helpers/destroy-app.js deleted file mode 100644 index e7f983bd14b..00000000000 --- a/blueprints/app/files/tests/helpers/destroy-app.js +++ /dev/null @@ -1,5 +0,0 @@ -import { run } from '@ember/runloop'; - -export default function destroyApp(application) { - run(application, 'destroy'); -} diff --git a/blueprints/app/files/tests/helpers/module-for-acceptance.js b/blueprints/app/files/tests/helpers/module-for-acceptance.js deleted file mode 100644 index 90a93bac2b4..00000000000 --- a/blueprints/app/files/tests/helpers/module-for-acceptance.js +++ /dev/null @@ -1,21 +0,0 @@ -import { module } from 'qunit'; -import { resolve } from 'rsvp'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; - -export default function(name, options = {}) { - module(name, { - beforeEach() { - this.application = startApp(); - - if (options.beforeEach) { - return options.beforeEach.apply(this, arguments); - } - }, - - afterEach() { - let afterEach = options.afterEach && options.afterEach.apply(this, arguments); - return resolve(afterEach).then(() => destroyApp(this.application)); - } - }); -} diff --git a/blueprints/app/files/tests/helpers/start-app.js b/blueprints/app/files/tests/helpers/start-app.js deleted file mode 100644 index 99d35dcf4eb..00000000000 --- a/blueprints/app/files/tests/helpers/start-app.js +++ /dev/null @@ -1,17 +0,0 @@ -import Application from '../../app'; -import config from '../../config/environment'; -import { merge } from '@ember/polyfills'; -import { run } from '@ember/runloop'; - -export default function startApp(attrs) { - let attributes = merge({}, config.APP); - attributes.autoboot = true; - attributes = merge(attributes, attrs); // use defaults, but you can override; - - return run(() => { - let application = Application.create(attributes); - application.setupForTesting(); - application.injectTestHelpers(); - return application; - }); -} diff --git a/blueprints/module-unification-app/files/tests/helpers/.gitkeep b/blueprints/module-unification-app/files/tests/helpers/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/blueprints/module-unification-app/files/tests/helpers/destroy-app.js b/blueprints/module-unification-app/files/tests/helpers/destroy-app.js deleted file mode 100644 index e7f983bd14b..00000000000 --- a/blueprints/module-unification-app/files/tests/helpers/destroy-app.js +++ /dev/null @@ -1,5 +0,0 @@ -import { run } from '@ember/runloop'; - -export default function destroyApp(application) { - run(application, 'destroy'); -} diff --git a/blueprints/module-unification-app/files/tests/helpers/module-for-acceptance.js b/blueprints/module-unification-app/files/tests/helpers/module-for-acceptance.js deleted file mode 100644 index 90a93bac2b4..00000000000 --- a/blueprints/module-unification-app/files/tests/helpers/module-for-acceptance.js +++ /dev/null @@ -1,21 +0,0 @@ -import { module } from 'qunit'; -import { resolve } from 'rsvp'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; - -export default function(name, options = {}) { - module(name, { - beforeEach() { - this.application = startApp(); - - if (options.beforeEach) { - return options.beforeEach.apply(this, arguments); - } - }, - - afterEach() { - let afterEach = options.afterEach && options.afterEach.apply(this, arguments); - return resolve(afterEach).then(() => destroyApp(this.application)); - } - }); -} diff --git a/blueprints/module-unification-app/files/tests/helpers/start-app.js b/blueprints/module-unification-app/files/tests/helpers/start-app.js deleted file mode 100644 index 00f3e4f53e5..00000000000 --- a/blueprints/module-unification-app/files/tests/helpers/start-app.js +++ /dev/null @@ -1,16 +0,0 @@ -import Application from '../../src/main'; -import config from '../../config/environment'; -import { run } from '@ember/runloop'; -import { merge } from '@ember/polyfills'; - -export default function startApp(attrs) { - let attributes = merge({}, config.APP); - attributes = merge(attributes, attrs); // use defaults, but you can override; - - return run(() => { - let application = Application.create(attributes); - application.setupForTesting(); - application.injectTestHelpers(); - return application; - }); -} diff --git a/tests/fixtures/addon/component-with-template/tests/acceptance/main-test.js b/tests/fixtures/addon/component-with-template/tests/acceptance/main-test.js index 86b31bd6b79..0ea3cfcd082 100644 --- a/tests/fixtures/addon/component-with-template/tests/acceptance/main-test.js +++ b/tests/fixtures/addon/component-with-template/tests/acceptance/main-test.js @@ -1,30 +1,22 @@ -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import Ember from 'ember'; +import { setupAcceptanceTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; -module('Acceptance', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); +module('Acceptance', function(hooks) { + setupApplicationTest(hooks); -test('renders properly', function(assert) { - visit('/'); + test('renders properly', async function(assert) { + await visit('/'); - andThen(function() { - var element = find('.basic-thing'); - assert.equal(element.first().text().trim(), 'WOOT!!'); + var element = this.element.querySelector('.basic-thing'); + assert.equal(element.textContent, 'WOOT!!'); }); -}); -test('renders imported component', function(assert) { - visit('/'); + test('renders imported component', async function(assert) { + await visit('/'); - andThen(function() { - var element = find('.second-thing'); - assert.equal(element.first().text().trim(), 'SECOND!!'); + var element = this.element.querySelector('.second-thing'); + assert.equal(element.textContent, 'SECOND!!'); }); }); diff --git a/tests/fixtures/addon/kitchen-sink/tests/acceptance/main-test.js b/tests/fixtures/addon/kitchen-sink/tests/acceptance/main-test.js index e38fea59aa4..102fd6cee8f 100644 --- a/tests/fixtures/addon/kitchen-sink/tests/acceptance/main-test.js +++ b/tests/fixtures/addon/kitchen-sink/tests/acceptance/main-test.js @@ -1,32 +1,24 @@ -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import Ember from 'ember'; +import { setupAcceptanceTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import truthyHelper from 'kitchen-sink/test-support/helper'; import { module, test } from 'qunit'; -module('Acceptance', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); +module('Acceptance', function(hooks) { + setupApplicationTest(hooks); -test('renders properly', function(assert) { - visit('/'); + test('renders properly', async function(assert) { + await visit('/'); - andThen(function() { - var element = find('.basic-thing'); - assert.equal(element.first().text().trim(), 'WOOT!!'); + var element = this.element.querySelector('.basic-thing'); + assert.equal(element.textContent, 'WOOT!!'); assert.ok(truthyHelper(), 'addon-test-support helper'); }); -}); -test('renders imported component', function(assert) { - visit('/'); + test('renders imported component', async function(assert) { + await visit('/'); - andThen(function() { - var element = find('.second-thing'); - assert.equal(element.first().text().trim(), 'SECOND!!'); + var element = this.element.querySelector('.second-thing'); + assert.equal(element.textContent, 'SECOND!!'); }); }); diff --git a/tests/fixtures/brocfile-tests/default-development/tests/integration/app-boots-test.js b/tests/fixtures/brocfile-tests/default-development/tests/integration/app-boots-test.js index 463e4f49f13..627ecd871e7 100644 --- a/tests/fixtures/brocfile-tests/default-development/tests/integration/app-boots-test.js +++ b/tests/fixtures/brocfile-tests/default-development/tests/integration/app-boots-test.js @@ -1,23 +1,15 @@ import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import { setupAcceptanceTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; -module('default-development - Integration', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); - -test('the application boots properly', function(assert) { - assert.expect(1); +module('default-development - Integration', function(hook) { + setupApplicationTest(hooks); - visit('/'); + test('renders properly', async function(assert) { + await visit('/'); - andThen(function() { - assert.ok(Ember.$('.ember-view').length > 0); + var elements = this.element.querySelectorAll('.ember-view'); + assert.ok(elements.length > 0); }); }); diff --git a/tests/fixtures/brocfile-tests/pods-templates/tests/integration/pods-template-test.js b/tests/fixtures/brocfile-tests/pods-templates/tests/integration/pods-template-test.js index c3f935290fd..c8ee821c209 100644 --- a/tests/fixtures/brocfile-tests/pods-templates/tests/integration/pods-template-test.js +++ b/tests/fixtures/brocfile-tests/pods-templates/tests/integration/pods-template-test.js @@ -1,23 +1,17 @@ import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import { setupAcceptanceTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; -module('pods based templates', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); +module('pods based templates', function(hooks) { + setupApplicationTest(hooks); -test('the application boots properly with pods based templates', function(assert) { - assert.expect(1); + test('the application boots properly with pods based templates', async function(assert) { + assert.expect(1); - visit('/'); + await visit('/'); - andThen(function() { - assert.equal(Ember.$('#title').text(), 'ZOMG, PODS WORKS!!'); + let actual = this.element.querySelector('#title').textContent + assert.equal(actual, 'ZOMG, PODS WORKS!!'); }); }); diff --git a/tests/fixtures/brocfile-tests/pods-with-prefix-templates/tests/integration/pods-template-test.js b/tests/fixtures/brocfile-tests/pods-with-prefix-templates/tests/integration/pods-template-test.js index 9c8795dd76c..16ffd4119a8 100644 --- a/tests/fixtures/brocfile-tests/pods-with-prefix-templates/tests/integration/pods-template-test.js +++ b/tests/fixtures/brocfile-tests/pods-with-prefix-templates/tests/integration/pods-template-test.js @@ -1,24 +1,17 @@ import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import { setupAcceptanceTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; -module('pods based templates', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); - +module('pods based templates', function(hooks) { + setupApplicationTest(hooks); -test('the application boots properly with pods based templates with a podModulePrefix set', function(assert) { - assert.expect(1); + test('the application boots properly with pods based templates with a podModulePrefix set', async function(assert) { + assert.expect(1); - visit('/'); + await visit('/'); - andThen(function() { - assert.equal(Ember.$('#title').text(), 'ZOMG, PODS WORKS!!'); + let actual = this.element.querySelector('#title').textContent + assert.equal(actual, 'ZOMG, PODS WORKS!!'); }); });