Skip to content

Commit

Permalink
Merge pull request #17689 from sukima/helper-blueprints-issue-17556
Browse files Browse the repository at this point in the history
Fix helper blueprint for module unification
  • Loading branch information
rwjblue committed Mar 2, 2019
2 parents 964a4fe + fbce668 commit 40ecde6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
5 changes: 5 additions & 0 deletions blueprints/helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const path = require('path');
module.exports = {
description: 'Generates a helper function.',

filesPath() {
let rootPath = isModuleUnificationProject(this.project) ? 'mu-files' : 'files';
return path.join(this.path, rootPath);
},

fileMapTokens() {
if (isModuleUnificationProject(this.project)) {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helper as buildHelper } from '@ember/component/helper';

export function <%= camelizedModuleName %>(params/*, hash*/) {
return params;
}

export const helper = buildHelper(<%= camelizedModuleName %>);
12 changes: 6 additions & 6 deletions node-tests/blueprints/helper-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('Blueprint: helper', function() {

it('helper foo/bar-baz', function() {
return emberGenerateDestroy(['helper', 'foo/bar-baz'], _file => {
expect(_file('src/ui/components/foo/bar-baz.js')).to.equal(fixture('helper/helper.js'));
expect(_file('src/ui/components/foo/bar-baz.js')).to.equal(fixture('helper/mu-helper.js'));
expect(_file('src/ui/components/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/integration.js')
);
Expand All @@ -115,7 +115,7 @@ describe('Blueprint: helper', function() {

it('helper foo/bar-baz unit', function() {
return emberGenerateDestroy(['helper', '--test-type=unit', 'foo/bar-baz'], _file => {
expect(_file('src/ui/components/foo/bar-baz.js')).to.equal(fixture('helper/helper.js'));
expect(_file('src/ui/components/foo/bar-baz.js')).to.equal(fixture('helper/mu-helper.js'));
expect(_file('src/ui/components/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/unit.js')
);
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('Blueprint: helper', function() {

it('helper foo/bar-baz', function() {
return emberGenerateDestroy(['helper', 'foo/bar-baz'], _file => {
expect(_file('src/ui/components/foo/bar-baz.js')).to.equal(fixture('helper/helper.js'));
expect(_file('src/ui/components/foo/bar-baz.js')).to.equal(fixture('helper/mu-helper.js'));
expect(_file('src/ui/components/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/integration.js')
);
Expand All @@ -179,7 +179,7 @@ describe('Blueprint: helper', function() {

it('helper foo/bar-baz unit', function() {
return emberGenerateDestroy(['helper', '--test-type=unit', 'foo/bar-baz'], _file => {
expect(_file('src/ui/components/foo/bar-baz.js')).to.equal(fixture('helper/helper.js'));
expect(_file('src/ui/components/foo/bar-baz.js')).to.equal(fixture('helper/mu-helper.js'));
expect(_file('src/ui/components/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/module-unification/addon-unit.js')
);
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('Blueprint: helper', function() {
it('helper foo/bar-baz --in-repo-addon=my-addon', function() {
return emberGenerateDestroy(['helper', 'foo/bar-baz', '--in-repo-addon=my-addon'], _file => {
expect(_file('packages/my-addon/src/ui/components/foo/bar-baz.js')).to.equal(
fixture('helper/helper.js')
fixture('helper/mu-helper.js')
);
expect(_file('packages/my-addon/src/ui/components/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/integration.js')
Expand All @@ -242,7 +242,7 @@ describe('Blueprint: helper', function() {
['helper', '--test-type=unit', 'foo/bar-baz', '--in-repo-addon=my-addon'],
_file => {
expect(_file('packages/my-addon/src/ui/components/foo/bar-baz.js')).to.equal(
fixture('helper/helper.js')
fixture('helper/mu-helper.js')
);
expect(_file('packages/my-addon/src/ui/components/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/module-unification/addon-unit.js')
Expand Down
7 changes: 7 additions & 0 deletions node-tests/fixtures/helper/mu-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helper as buildHelper } from '@ember/component/helper';

export function fooBarBaz(params/*, hash*/) {
return params;
}

export const helper = buildHelper(fooBarBaz);

0 comments on commit 40ecde6

Please sign in to comment.