Skip to content

fix(generate): missing string-utils and empty test #547

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

Merged
merged 2 commits into from
Apr 27, 2016
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
28 changes: 14 additions & 14 deletions addon/ng2/blueprints/component/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var path = require('path');
var stringUtils = require('ember-cli-string-utils');
var chalk = require('chalk');
var Blueprint = require('ember-cli/lib/models/blueprint');
var dynamicPathParser = require('../../utilities/dynamic-path-parser');
var addBarrelRegistration = require('../../utilities/barrel-management');
var getFiles = Blueprint.prototype.files;
const stringUtils = require('ember-cli/lib/utilities/string');

module.exports = {
description: '',

availableOptions: [
{ name: 'flat', type: Boolean, default: false },
{ name: 'route', type: Boolean, default: false },
Expand All @@ -21,27 +21,27 @@ module.exports = {
var parsedPath = dynamicPathParser(this.project, entityName);

this.dynamicPath = parsedPath;

var defaultPrefix = '';
if (this.project.ngConfig &&
if (this.project.ngConfig &&
this.project.ngConfig.defaults &&
this.project.ngConfig.defaults.prefix) {
defaultPrefix = this.project.ngConfig.defaults.prefix + '-';
}
var prefix = this.options.prefix ? defaultPrefix : '';
this.selector = stringUtils.dasherize(prefix + parsedPath.name);

if (this.selector.indexOf('-') === -1) {
this._writeStatusToUI(chalk.yellow, 'WARNING', 'selectors should contain a dash');
}

return parsedPath.name;
},

locals: function (options) {
//TODO: pull value from config
this.styleExt = 'css';

return {
dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''),
flat: options.flat,
Expand All @@ -54,10 +54,10 @@ module.exports = {
selector: this.selector
};
},

files: function() {
var fileList = getFiles.call(this);

if (this.options && this.options.flat) {
fileList = fileList.filter(p => p.indexOf('index.ts') <= 0);
}
Expand All @@ -73,15 +73,15 @@ module.exports = {

return fileList;
},

fileMapTokens: function (options) {
// Return custom template variables here.
return {
__path__: () => {
var dir = this.dynamicPath.dir;
if (!options.locals.flat) {
dir += path.sep + options.dasherizedModuleName;

if (options.locals.isLazyRoute) {
var dirParts = dir.split(path.sep);
dirParts[dirParts.length - 1] = `+${dirParts[dirParts.length - 1]}`;
Expand All @@ -97,12 +97,12 @@ module.exports = {
}
};
},

afterInstall: function(options) {
if (!options.flat) {
var filePath = path.join('src', 'client', 'system-config.ts');
var barrelUrl = this.appDir.replace(path.sep, '/');

return addBarrelRegistration(this, this.generatePath)
.then(() => {
return this.insertIntoFile(
Expand All @@ -113,7 +113,7 @@ module.exports = {
})
} else {
return addBarrelRegistration(
this,
this,
this.generatePath,
options.entity.name + '.component');
}
Expand Down
14 changes: 6 additions & 8 deletions tests/acceptance/generate-component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('Acceptance: ng generate component', function () {
expect(existsSync(testPath)).to.equal(false);
});
});

it('ng generate component mycomp will prefix selector', () => {
return ng(['generate', 'component', 'mycomp'])
.then(() => {
Expand All @@ -148,7 +148,7 @@ describe('Acceptance: ng generate component', function () {
expect(contents.indexOf('selector: \'app-mycomp\'') === -1).to.equal(false);
});
});

it('ng generate component mycomp --no-prefix will not prefix selector', () => {
return ng(['generate', 'component', 'mycomp', '--no-prefix'])
.then(() => {
Expand All @@ -158,29 +158,27 @@ describe('Acceptance: ng generate component', function () {
expect(contents.indexOf('selector: \'mycomp\'') === -1).to.equal(false);
});
});

it('ng generate component myComp will succeed', () => {
return ng(['generate', 'component', 'myComp'])
.then(() => {
var testPath = path.join(root, 'tmp', 'foo', 'src', 'client', 'app', 'my-comp', 'my-comp.component.ts');
expect(existsSync(testPath)).to.equal(true);
});
});

it('ng generate component my-comp --inline-template', function () {
return ng(['generate', 'component', 'my-comp', '--inline-template']).then(() => {
var testPath = path.join(root, 'tmp', 'foo', 'src', 'client', 'app', 'my-comp', 'my-comp.component.html');
expect(existsSync(testPath)).to.equal(false);
});
});

it('ng generate component my-comp --inline-style', function () {
return ng(['generate', 'component', 'my-comp', '--inline-style']).then(() => {
var testPath = path.join(root, 'tmp', 'foo', 'src', 'client', 'app', 'my-comp', 'my-comp.component.css');
expect(existsSync(testPath)).to.equal(false);
});
});

it('should ', () => {
});

});