Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blueprints/controller-test: Add RFC232 variants #15943

Merged
merged 2 commits into from
Dec 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do needs go? Should we indicate how those can be added to the registry or is this not a thing anymore?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gloriously not a thing anymore.

to stub out lookups (if need be) we use this.owner.register -- example:

this.owner.register('service:feature', Service.extend({
    myFeature: false
});

probably don't need to document that here though


// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.owner.lookup('controller:<%= controllerPathName %>');
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.lookup('controller:foo');
assert.ok(controller);
});
});