Skip to content

Commit 1e36273

Browse files
authored
Merge branch 'master' into angular-2.1.0
2 parents 6c7461e + c2dd94c commit 1e36273

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

packages/angular-cli/blueprints/class/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ const getFiles = Blueprint.prototype.files;
66
module.exports = {
77
description: '',
88

9-
anonymousOptions: [
10-
'<class-type>'
11-
],
12-
139
availableOptions: [
1410
{ name: 'spec', type: Boolean }
1511
],
1612

1713
normalizeEntityName: function (entityName) {
18-
var parsedPath = dynamicPathParser(this.project, entityName);
14+
var parsedPath = dynamicPathParser(this.project, entityName.split('.')[0]);
1915

2016
this.dynamicPath = parsedPath;
2117
return parsedPath.name;
2218
},
2319

2420
locals: function (options) {
25-
var classType = options.args [2]
21+
const rawName = options.args[1];
22+
const nameParts = rawName.split('.')
23+
.filter(part => part.length !== 0);
24+
25+
const classType = nameParts[1];
2626
this.fileName = stringUtils.dasherize(options.entity.name);
2727
if (classType) {
28-
this.fileName += '.' + classType;
28+
this.fileName += '.' + classType.toLowerCase();
2929
}
3030

3131
options.spec = options.spec !== undefined ?
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
/* tslint:disable:no-unused-variable */
2+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3+
import { By } from '@angular/platform-browser';
4+
import { DebugElement } from '@angular/core';
25

3-
import { TestBed, async } from '@angular/core/testing';
46
import { <%= classifiedModuleName %>Component } from './<%= dasherizedModuleName %>.component';
57

6-
describe('Component: <%= classifiedModuleName %>', () => {
7-
it('should create an instance', () => {
8-
let component = new <%= classifiedModuleName %>Component();
8+
describe('<%= classifiedModuleName %>Component', () => {
9+
let component: <%= classifiedModuleName %>Component;
10+
let fixture: ComponentFixture<<%= classifiedModuleName %>Component>;
11+
12+
beforeEach(async(() => {
13+
TestBed.configureTestingModule({
14+
declarations: [ <%= classifiedModuleName %>Component ]
15+
})
16+
.compileComponents();
17+
}));
18+
19+
beforeEach(() => {
20+
fixture = TestBed.createComponent(<%= classifiedModuleName %>Component);
21+
component = fixture.componentInstance;
22+
fixture.detectChanges();
23+
});
24+
25+
it('should create', () => {
926
expect(component).toBeTruthy();
1027
});
1128
});

tests/acceptance/generate-class.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ describe('Acceptance: ng generate class', function () {
4343
});
4444
});
4545

46-
it('ng generate class my-class model', function () {
47-
return ng(['generate', 'class', 'my-class', 'model']).then(() => {
46+
it('ng generate class my-class.model', function () {
47+
return ng(['generate', 'class', 'my-class.model']).then(() => {
4848
expect(existsSync(path.join(testPath, 'my-class.model.ts'))).to.equal(true);
4949
});
5050
});
@@ -55,8 +55,8 @@ describe('Acceptance: ng generate class', function () {
5555
});
5656
});
5757

58-
it(`ng generate class shared${path.sep}my-class model`, function () {
59-
return ng(['generate', 'class', 'shared/my-class', 'model']).then(() => {
58+
it(`ng generate class shared${path.sep}my-class.model`, function () {
59+
return ng(['generate', 'class', 'shared/my-class.model']).then(() => {
6060
expect(existsSync(path.join(testPath, 'shared', 'my-class.model.ts'))).to.equal(true);
6161
});
6262
});

0 commit comments

Comments
 (0)