Skip to content

feat(tests): allow to create component without a spec file #1484

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 1 commit into from
Jul 28, 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
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);
});
})
});