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

[CLEANUP beta] remove the --test-type option from the helper blueprint #19808

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 4 additions & 22 deletions blueprints/helper-test/index.js
Expand Up @@ -7,29 +7,15 @@ const semver = require('semver');
const useTestFrameworkDetector = require('../test-framework-detector');

module.exports = useTestFrameworkDetector({
description: 'Generates a helper integration test or a unit test.',

availableOptions: [
{
name: 'test-type',
type: ['integration', 'unit'],
default: 'integration',
aliases: [
{ i: 'integration' },
{ u: 'unit' },
{ integration: 'integration' },
{ unit: 'unit' },
],
},
],
description: 'Generates a helper integration test.',

fileMapTokens: function () {
return {
__root__() {
return 'tests';
},
__testType__(options) {
return options.locals.testType || 'integration';
__testType__() {
return 'integration';
},
__collection__() {
return 'helpers';
Expand All @@ -38,17 +24,14 @@ module.exports = useTestFrameworkDetector({
},

locals: function (options) {
let testType = options.testType || 'integration';
let testName = testType === 'integration' ? 'Integration' : 'Unit';
let friendlyTestName = [testName, 'Helper', options.entity.name].join(' | ');
let friendlyTestName = ['Integration', 'Helper', options.entity.name].join(' | ');
let dasherizedModulePrefix = stringUtils.dasherize(options.project.config().modulePrefix);

let hbsImportStatement = this._useNamedHbsImport()
? "import { hbs } from 'ember-cli-htmlbars';"
: "import hbs from 'htmlbars-inline-precompile';";

return {
testType,
friendlyTestName,
dasherizedModulePrefix,
hbsImportStatement,
Expand All @@ -68,7 +51,6 @@ module.exports = useTestFrameworkDetector({
afterInstall: function (options) {
if (
!options.dryRun &&
options.testType === 'integration' &&
!this._useNamedHbsImport() &&
isPackageMissing(this, 'ember-cli-htmlbars-inline-precompile')
) {
Expand Down
@@ -1,5 +1,5 @@
import { expect } from 'chai';
<% if (testType == 'integration') { %>import { describe, it } from 'mocha';
import { describe, it } from 'mocha';
import { setupComponentTest } from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';

Expand All @@ -24,15 +24,3 @@ describe('<%= friendlyTestName %>', function() {
expect(this.$().text().trim()).to.equal('1234');
});
});
<% } else if (testType == 'unit') { %>import { describe, it } from 'mocha';
import { <%= camelizedModuleName %> } from '<%= dasherizedPackageName %>/helpers/<%= dasherizedModuleName %>';

describe('<%= friendlyTestName %>', function() {

// TODO: Replace this with your real tests.
it('works', function() {
let result = <%= camelizedModuleName %>(42);
expect(result).to.be.ok;
});
});
<% } %>
@@ -1,5 +1,4 @@
import { expect } from 'chai';
<% if (testType == 'integration') { %>
import { describeComponent, it } from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';

Expand All @@ -25,15 +24,3 @@ describeComponent('<%= dasherizedModuleName %>', 'helper:<%= dasherizedModuleNam
});
}
);
<% } else if (testType == 'unit') { %>import { describe, it } from 'mocha';
import { <%= camelizedModuleName %> } from '<%= dasherizedPackageName %>/helpers/<%= dasherizedModuleName %>';

describe('<%= friendlyTestName %>', function() {

// TODO: Replace this with your real tests.
it('works', function() {
let result = <%= camelizedModuleName %>(42);
expect(result).to.be.ok;
});
});
<% } %>
@@ -1,5 +1,5 @@
import { expect } from 'chai';
<% if (testType == 'integration') { %>import { describe, it } from 'mocha';
import { describe, it } from 'mocha';
import { setupRenderingTest } from 'ember-mocha';
import { render } from '@ember/test-helpers';
<%= hbsImportStatement %>
Expand All @@ -15,14 +15,4 @@ describe('<%= friendlyTestName %>', function() {

expect(this.element.textContent.trim()).to.equal('1234');
});
});<% } else if (testType == 'unit') { %>import { describe, it } from 'mocha';
import { <%= camelizedModuleName %> } from '<%= dasherizedPackageName %>/helpers/<%= dasherizedModuleName %>';

describe('<%= friendlyTestName %>', function() {

// TODO: Replace this with your real tests.
it('works', function() {
let result = <%= camelizedModuleName %>(42);
expect(result).to.be.ok;
});
});<% } %>
});
@@ -1,4 +1,4 @@
<% if (testType == 'integration') { %>import { moduleForComponent, test } from 'ember-qunit';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('<%= dasherizedModuleName %>', 'helper:<%= dasherizedModuleName %>', {
Expand All @@ -12,15 +12,4 @@ test('it renders', function(assert) {
this.render(hbs`{{<%= dasherizedModuleName %> this.inputValue}}`);

assert.equal(this.$().text().trim(), '1234');
});<% } else if (testType == 'unit') { %>
import { <%= camelizedModuleName %> } from '<%= dasherizedModulePrefix %>/helpers/<%= dasherizedModuleName %>';
import { module, test } from 'qunit';

module('<%= friendlyTestName %>');

// TODO: Replace this with your real tests.
test('it works', function(assert) {
let result = <%= camelizedModuleName %>([42]);
assert.ok(result);
});
<% } %>
@@ -1,4 +1,4 @@
<% if (testType === 'integration') { %>import { module, test } from 'qunit';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
<%= hbsImportStatement %>
Expand All @@ -14,16 +14,4 @@ module('<%= friendlyTestName %>', function(hooks) {

assert.dom(this.element).hasText('1234');
});
});<% } else if (testType === 'unit') { %>import { <%= camelizedModuleName %> } from '<%= dasherizedModulePrefix %>/helpers/<%= dasherizedModuleName %>';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('<%= friendlyTestName %>', function(hooks) {
setupTest(hooks);

// TODO: Replace this with your real tests.
test('it works', function(assert) {
let result = <%= camelizedModuleName %>([42]);
assert.ok(result);
});
});<% } %>
});
38 changes: 3 additions & 35 deletions node-tests/blueprints/helper-test-test.js
Expand Up @@ -37,8 +37,8 @@ describe('Blueprint: helper-test', function () {
});
});

it('helper-test foo/bar-baz --integration', function () {
return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--integration'], (_file) => {
it('helper-test foo/bar-baz', function () {
return emberGenerateDestroy(['helper-test', 'foo/bar-baz'], (_file) => {
expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/integration.js')
);
Expand All @@ -62,14 +62,6 @@ describe('Blueprint: helper-test', function () {
);
});
});

it('helper-test foo/bar-baz --unit', function () {
return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--unit'], (_file) => {
expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/rfc232-unit.js')
);
});
});
});

describe('with ember-cli-mocha@0.11.0', function () {
Expand All @@ -81,21 +73,13 @@ describe('Blueprint: helper-test', function () {
generateFakePackageManifest('ember-cli-mocha', '0.11.0');
});

it('helper-test foo/bar-baz --integration', function () {
it('helper-test foo/bar-baz', function () {
return emberGenerateDestroy(['helper-test', 'foo/bar-baz'], (_file) => {
expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/mocha.js')
);
});
});

it('helper-test foo/bar-baz --unit', function () {
return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--unit'], (_file) => {
expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/mocha-unit.js')
);
});
});
});

describe('with ember-cli-mocha@0.12.0', function () {
Expand All @@ -114,14 +98,6 @@ describe('Blueprint: helper-test', function () {
);
});
});

it('helper-test foo/bar-baz for mocha --unit', function () {
return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--unit'], (_file) => {
expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/mocha-0.12-unit.js')
);
});
});
});

describe('with ember-mocha@0.14.0', function () {
Expand All @@ -140,14 +116,6 @@ describe('Blueprint: helper-test', function () {
);
});
});

it('helper-test foo/bar-baz for mocha --unit', function () {
return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--unit'], (_file) => {
expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/mocha-rfc232-unit.js')
);
});
});
});
});

Expand Down
9 changes: 0 additions & 9 deletions node-tests/blueprints/helper-test.js
Expand Up @@ -48,15 +48,6 @@ describe('Blueprint: helper', function () {
});
});

it('helper foo/bar-baz unit', function () {
return emberGenerateDestroy(['helper', '--test-type=unit', 'foo/bar-baz'], (_file) => {
expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper/helper.js'));
expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/unit.js')
);
});
});

it('helper foo/bar-baz --pod', function () {
return emberGenerateDestroy(['helper', 'foo/bar-baz', '--pod'], (_file) => {
expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper/helper.js'));
Expand Down
13 changes: 0 additions & 13 deletions node-tests/fixtures/helper-test/mocha-0.12-unit.js

This file was deleted.

1 change: 0 additions & 1 deletion node-tests/fixtures/helper-test/mocha-0.12.js
Expand Up @@ -24,4 +24,3 @@ describe('Integration | Helper | foo/bar-baz', function() {
expect(this.$().text().trim()).to.equal('1234');
});
});

12 changes: 0 additions & 12 deletions node-tests/fixtures/helper-test/mocha-rfc232-unit.js

This file was deleted.

13 changes: 0 additions & 13 deletions node-tests/fixtures/helper-test/mocha-unit.js

This file was deleted.

2 changes: 0 additions & 2 deletions node-tests/fixtures/helper-test/mocha.js
@@ -1,5 +1,4 @@
import { expect } from 'chai';

Windvis marked this conversation as resolved.
Show resolved Hide resolved
import { describeComponent, it } from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';

Expand All @@ -25,4 +24,3 @@ describeComponent('foo/bar-baz', 'helper:foo/bar-baz',
});
}
);

12 changes: 0 additions & 12 deletions node-tests/fixtures/helper-test/module-unification/addon-unit.js

This file was deleted.

13 changes: 0 additions & 13 deletions node-tests/fixtures/helper-test/rfc232-unit.js

This file was deleted.

12 changes: 0 additions & 12 deletions node-tests/fixtures/helper-test/unit.js

This file was deleted.