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); + }); +});