Skip to content

Commit a85a507

Browse files
committed
feat(tests): allow to create component without a spec file
Fixes #1256
1 parent c5701c2 commit a85a507

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

addon/ng2/blueprints/component/index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module.exports = {
1414
{ name: 'route', type: Boolean, default: false },
1515
{ name: 'inline-template', type: Boolean, default: false, aliases: ['it'] },
1616
{ name: 'inline-style', type: Boolean, default: false, aliases: ['is'] },
17-
{ name: 'prefix', type: Boolean, default: true }
17+
{ name: 'prefix', type: Boolean, default: true },
18+
{ name: 'nospec', type: Boolean, default: false }
1819
],
1920

2021
normalizeEntityName: function (entityName) {
@@ -49,6 +50,7 @@ module.exports = {
4950
return {
5051
dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''),
5152
flat: options.flat,
53+
nospec: options.nospec,
5254
inlineTemplate: options.inlineTemplate,
5355
inlineStyle: options.inlineStyle,
5456
route: options.route,
@@ -74,6 +76,9 @@ module.exports = {
7476
if (this.options && this.options.inlineStyle) {
7577
fileList = fileList.filter(p => p.indexOf('.__styleext__') < 0);
7678
}
79+
if (this.options && this.options.nospec) {
80+
fileList = fileList.filter(p => p.indexOf('__name__.component.spec.ts') < 0);
81+
}
7782

7883
return fileList;
7984
},

tests/acceptance/generate-component.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,11 @@ describe('Acceptance: ng generate component', function () {
178178
expect(existsSync(testPath)).to.equal(false);
179179
});
180180
});
181+
182+
it('ng generate component my-comp --nospec', function() {
183+
return ng(['generate', 'component', 'my-comp', '--nospec']).then(() => {
184+
var testPath = path.join(root, 'tmp', 'foo', 'src', 'app', 'my-comp', 'my-comp.component.spec.ts');
185+
expect(existsSync(testPath)).to.equal(false);
186+
});
187+
})
181188
});

0 commit comments

Comments
 (0)