Skip to content

Commit

Permalink
feat(tests): allow to create component without a spec file
Browse files Browse the repository at this point in the history
Fixes #1256
  • Loading branch information
Brocco committed Jul 28, 2016
1 parent c5701c2 commit a85a507
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion addon/ng2/blueprints/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ module.exports = {
{ name: 'route', type: Boolean, default: false },
{ name: 'inline-template', type: Boolean, default: false, aliases: ['it'] },
{ name: 'inline-style', type: Boolean, default: false, aliases: ['is'] },
{ name: 'prefix', type: Boolean, default: true }
{ name: 'prefix', type: Boolean, default: true },
{ name: 'nospec', type: Boolean, default: false }
],

normalizeEntityName: function (entityName) {
Expand Down Expand Up @@ -49,6 +50,7 @@ module.exports = {
return {
dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''),
flat: options.flat,
nospec: options.nospec,
inlineTemplate: options.inlineTemplate,
inlineStyle: options.inlineStyle,
route: options.route,
Expand All @@ -74,6 +76,9 @@ module.exports = {
if (this.options && this.options.inlineStyle) {
fileList = fileList.filter(p => p.indexOf('.__styleext__') < 0);
}
if (this.options && this.options.nospec) {
fileList = fileList.filter(p => p.indexOf('__name__.component.spec.ts') < 0);
}

return fileList;
},
Expand Down
7 changes: 7 additions & 0 deletions tests/acceptance/generate-component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,11 @@ describe('Acceptance: ng generate component', function () {
expect(existsSync(testPath)).to.equal(false);
});
});

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

0 comments on commit a85a507

Please sign in to comment.