Skip to content

Commit

Permalink
blueprints/controller-test: Add RFC232 variants
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Dec 8, 2017
1 parent 5e8b75c commit 345ba24
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions blueprints/controller-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

/* eslint-env node */

const stringUtil = require('ember-cli-string-utils');
const testInfo = require('ember-cli-test-info');

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')
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});
});
13 changes: 13 additions & 0 deletions node-tests/blueprints/controller-test-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
12 changes: 12 additions & 0 deletions node-tests/fixtures/controller-test/rfc232.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit 345ba24

Please sign in to comment.