From 4fc1370b6eec39a0dd3b98ca1bb3e002b061500a Mon Sep 17 00:00:00 2001 From: snewcomer24 Date: Fri, 8 Dec 2017 08:55:24 -0800 Subject: [PATCH 1/2] blueprints/initializer-test: Add RFC232 variants --- .../tests/unit/initializers/__name__-test.js | 29 +++++++++++++++++++ .../blueprints/initializer-test-test.js | 14 +++++++++ .../fixtures/initializer-test/rfc232.js | 29 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 blueprints/initializer-test/qunit-rfc-232-files/tests/unit/initializers/__name__-test.js create mode 100644 node-tests/fixtures/initializer-test/rfc232.js diff --git a/blueprints/initializer-test/qunit-rfc-232-files/tests/unit/initializers/__name__-test.js b/blueprints/initializer-test/qunit-rfc-232-files/tests/unit/initializers/__name__-test.js new file mode 100644 index 00000000000..0a8c159b505 --- /dev/null +++ b/blueprints/initializer-test/qunit-rfc-232-files/tests/unit/initializers/__name__-test.js @@ -0,0 +1,29 @@ +import Application from '@ember/application'; +import { run } from '@ember/runloop'; + +import { initialize } from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; +import destroyApp from '../../helpers/destroy-app'; + +module('<%= friendlyTestName %>', function(hooks) { + setupTest(hooks); + + hooks.beforeEach(function() { + run(() => { + this.application = Application.create(); + this.application.deferReadiness(); + }); + }); + hooks.afterEach(function() { + destroyApp(this.application); + }); + + // Replace this with your real tests. + test('it works', function(assert) { + initialize(this.application); + + // you would normally confirm the results of the initializer here + assert.ok(true); + }); +}); diff --git a/node-tests/blueprints/initializer-test-test.js b/node-tests/blueprints/initializer-test-test.js index ac42372733f..6d639b2be2a 100644 --- a/node-tests/blueprints/initializer-test-test.js +++ b/node-tests/blueprints/initializer-test-test.js @@ -9,6 +9,7 @@ const modifyPackages = blueprintHelpers.modifyPackages; const chai = require('ember-cli-blueprint-test-helpers/chai'); const expect = chai.expect; +const generateFakePackageManifest = require('../helpers/generate-fake-package-manifest'); const fixture = require('../helpers/fixture'); describe('Blueprint: initializer-test', function() { @@ -26,6 +27,19 @@ describe('Blueprint: initializer-test', function() { }); }); + describe('with ember-cli-qunit@4.1.1', function() { + beforeEach(function() { + generateFakePackageManifest('ember-cli-qunit', '4.1.1'); + }); + + it('initializer-test foo', function() { + return emberGenerateDestroy(['initializer-test', 'foo'], _file => { + expect(_file('tests/unit/initializers/foo-test.js')) + .to.equal(fixture('initializer-test/rfc232.js')); + }); + }); + }); + describe('with ember-cli-mocha', function() { beforeEach(function() { modifyPackages([ diff --git a/node-tests/fixtures/initializer-test/rfc232.js b/node-tests/fixtures/initializer-test/rfc232.js new file mode 100644 index 00000000000..c2594664161 --- /dev/null +++ b/node-tests/fixtures/initializer-test/rfc232.js @@ -0,0 +1,29 @@ +import Application from '@ember/application'; +import { run } from '@ember/runloop'; + +import { initialize } from 'my-app/initializers/foo'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; +import destroyApp from '../../helpers/destroy-app'; + +module('Unit | Initializer | foo', function(hooks) { + setupTest(hooks); + + hooks.beforeEach(function() { + run(() => { + this.application = Application.create(); + this.application.deferReadiness(); + }); + }); + hooks.afterEach(function() { + destroyApp(this.application); + }); + + // Replace this with your real tests. + test('it works', function(assert) { + initialize(this.application); + + // you would normally confirm the results of the initializer here + assert.ok(true); + }); +}); From 7f135327e121c7be3a2e02b52f66f9ca669c0908 Mon Sep 17 00:00:00 2001 From: snewcomer24 Date: Sat, 9 Dec 2017 18:40:31 -0800 Subject: [PATCH 2/2] fix based on comments --- .../tests/unit/initializers/__name__-test.js | 16 +++++++++------- node-tests/fixtures/initializer-test/rfc232.js | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/blueprints/initializer-test/qunit-rfc-232-files/tests/unit/initializers/__name__-test.js b/blueprints/initializer-test/qunit-rfc-232-files/tests/unit/initializers/__name__-test.js index 0a8c159b505..d4785e0ed6c 100644 --- a/blueprints/initializer-test/qunit-rfc-232-files/tests/unit/initializers/__name__-test.js +++ b/blueprints/initializer-test/qunit-rfc-232-files/tests/unit/initializers/__name__-test.js @@ -1,5 +1,4 @@ import Application from '@ember/application'; -import { run } from '@ember/runloop'; import { initialize } from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>'; import { module, test } from 'qunit'; @@ -10,20 +9,23 @@ module('<%= friendlyTestName %>', function(hooks) { setupTest(hooks); hooks.beforeEach(function() { - run(() => { - this.application = Application.create(); - this.application.deferReadiness(); + this.TestApplication = Application.extend(); + this.TestApplication.initializer({ + name: 'initializer under test', + initialize }); + + this.application = this.TestApplication.create({ autoboot: false }); }); + hooks.afterEach(function() { destroyApp(this.application); }); // Replace this with your real tests. - test('it works', function(assert) { - initialize(this.application); + test('it works', async function(assert) { + await this.application.boot(); - // you would normally confirm the results of the initializer here assert.ok(true); }); }); diff --git a/node-tests/fixtures/initializer-test/rfc232.js b/node-tests/fixtures/initializer-test/rfc232.js index c2594664161..7586f355d13 100644 --- a/node-tests/fixtures/initializer-test/rfc232.js +++ b/node-tests/fixtures/initializer-test/rfc232.js @@ -1,5 +1,4 @@ import Application from '@ember/application'; -import { run } from '@ember/runloop'; import { initialize } from 'my-app/initializers/foo'; import { module, test } from 'qunit'; @@ -10,20 +9,23 @@ module('Unit | Initializer | foo', function(hooks) { setupTest(hooks); hooks.beforeEach(function() { - run(() => { - this.application = Application.create(); - this.application.deferReadiness(); + this.TestApplication = Application.extend(); + this.TestApplication.initializer({ + name: 'initializer under test', + initialize }); + + this.application = this.TestApplication.create({ autoboot: false }); }); + hooks.afterEach(function() { destroyApp(this.application); }); // Replace this with your real tests. - test('it works', function(assert) { - initialize(this.application); + test('it works', async function(assert) { + await this.application.boot(); - // you would normally confirm the results of the initializer here assert.ok(true); }); });