From 345ba248495abb105def1722b834882b1fc5e85d Mon Sep 17 00:00:00 2001 From: snewcomer24 Date: Thu, 7 Dec 2017 14:32:29 -0800 Subject: [PATCH 1/2] blueprints/controller-test: Add RFC232 variants --- blueprints/controller-test/index.js | 4 ++++ .../tests/unit/__path__/__test__.js | 12 ++++++++++++ node-tests/blueprints/controller-test-test.js | 13 +++++++++++++ node-tests/fixtures/controller-test/rfc232.js | 12 ++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 blueprints/controller-test/qunit-rfc-232-files/tests/unit/__path__/__test__.js create mode 100644 node-tests/fixtures/controller-test/rfc232.js diff --git a/blueprints/controller-test/index.js b/blueprints/controller-test/index.js index 58a133bb5d1..cb529db2ff0 100644 --- a/blueprints/controller-test/index.js +++ b/blueprints/controller-test/index.js @@ -2,6 +2,7 @@ /* eslint-env node */ +const stringUtil = require('ember-cli-string-utils'); const testInfo = require('ember-cli-test-info'); const useTestFrameworkDetector = require('../test-framework-detector'); @@ -9,7 +10,10 @@ const useTestFrameworkDetector = require('../test-framework-detector'); module.exports = useTestFrameworkDetector({ description: 'Generates a controller unit test.', locals: function(options) { + let dasherizedModuleName = stringUtil.dasherize(options.entity.name); + let controllerPathName = dasherizedModuleName; return { + controllerPathName: controllerPathName, friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Controller') }; } diff --git a/blueprints/controller-test/qunit-rfc-232-files/tests/unit/__path__/__test__.js b/blueprints/controller-test/qunit-rfc-232-files/tests/unit/__path__/__test__.js new file mode 100644 index 00000000000..3622039f9ce --- /dev/null +++ b/blueprints/controller-test/qunit-rfc-232-files/tests/unit/__path__/__test__.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('<%= friendlyTestDescription %>', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.factoryFor('controller:<%= controllerPathName %>').create(); + assert.ok(controller); + }); +}); diff --git a/node-tests/blueprints/controller-test-test.js b/node-tests/blueprints/controller-test-test.js index 2a2009b879a..b17ce22a499 100644 --- a/node-tests/blueprints/controller-test-test.js +++ b/node-tests/blueprints/controller-test-test.js @@ -27,6 +27,19 @@ describe('Blueprint: controller-test', function() { }); }); + describe('with ember-cli-qunit@4.1.1', function() { + beforeEach(function() { + generateFakePackageManifest('ember-cli-qunit', '4.1.1'); + }); + + it('controller-test foo', function() { + return emberGenerateDestroy(['controller-test', 'foo'], _file => { + expect(_file('tests/unit/controllers/foo-test.js')) + .to.equal(fixture('controller-test/rfc232.js')); + }); + }); + }); + describe('with ember-cli-mocha@0.11.0', function() { beforeEach(function() { modifyPackages([ diff --git a/node-tests/fixtures/controller-test/rfc232.js b/node-tests/fixtures/controller-test/rfc232.js new file mode 100644 index 00000000000..f6efbf862b6 --- /dev/null +++ b/node-tests/fixtures/controller-test/rfc232.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | foo', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.factoryFor('controller:foo').create(); + assert.ok(controller); + }); +}); From 8f8709a8f58cdf40a6f2c61542da9524ee21ce5e Mon Sep 17 00:00:00 2001 From: snewcomer24 Date: Sat, 9 Dec 2017 09:07:13 -0800 Subject: [PATCH 2/2] use lookup instead of create --- .../qunit-rfc-232-files/tests/unit/__path__/__test__.js | 2 +- node-tests/fixtures/controller-test/rfc232.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blueprints/controller-test/qunit-rfc-232-files/tests/unit/__path__/__test__.js b/blueprints/controller-test/qunit-rfc-232-files/tests/unit/__path__/__test__.js index 3622039f9ce..e6f57bf8780 100644 --- a/blueprints/controller-test/qunit-rfc-232-files/tests/unit/__path__/__test__.js +++ b/blueprints/controller-test/qunit-rfc-232-files/tests/unit/__path__/__test__.js @@ -6,7 +6,7 @@ module('<%= friendlyTestDescription %>', function(hooks) { // Replace this with your real tests. test('it exists', function(assert) { - let controller = this.owner.factoryFor('controller:<%= controllerPathName %>').create(); + let controller = this.owner.lookup('controller:<%= controllerPathName %>'); assert.ok(controller); }); }); diff --git a/node-tests/fixtures/controller-test/rfc232.js b/node-tests/fixtures/controller-test/rfc232.js index f6efbf862b6..2b12450677c 100644 --- a/node-tests/fixtures/controller-test/rfc232.js +++ b/node-tests/fixtures/controller-test/rfc232.js @@ -6,7 +6,7 @@ module('Unit | Controller | foo', function(hooks) { // Replace this with your real tests. test('it exists', function(assert) { - let controller = this.owner.factoryFor('controller:foo').create(); + let controller = this.owner.lookup('controller:foo'); assert.ok(controller); }); });