From 4fc1370b6eec39a0dd3b98ca1bb3e002b061500a Mon Sep 17 00:00:00 2001 From: snewcomer24 Date: Fri, 8 Dec 2017 08:55:24 -0800 Subject: [PATCH] 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); + }); +});