Skip to content

Commit 12575ef

Browse files
MeligyMRHarrison
authored andcommitted
feat(new): include routing in spec and inline template when called with --routing (angular#3252)
1 parent 86c8db5 commit 12575ef

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.spec.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
/* tslint:disable:no-unused-variable */
22

3-
import { TestBed, async } from '@angular/core/testing';
3+
import { TestBed, async } from '@angular/core/testing';<% if (routing) { %>
4+
import { RouterTestingModule } from '@angular/router/testing';<% } %>
45
import { AppComponent } from './app.component';
56

67
describe('AppComponent', () => {
78
beforeEach(() => {
8-
TestBed.configureTestingModule({
9+
TestBed.configureTestingModule({<% if (routing) { %>
10+
imports: [
11+
RouterTestingModule
12+
],<% } %>
913
declarations: [
1014
AppComponent
1115
],
1216
});
17+
TestBed.compileComponents();
1318
});
1419

1520
it('should create the app', async(() => {

packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { APP_SHELL_DIRECTIVES } from '@angular/app-shell';<% } %>
66
template: `
77
<h1>
88
{{title}}
9-
</h1>
9+
</h1><% if (routing) { %>
10+
<router-outlet></router-outlet><% } %>
1011
`,<% } else { %>
1112
templateUrl: './app.component.html',<% } %><% if (inlineStyle) { %>
1213
styles: []<% } else { %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as path from 'path';
2+
import {ng} from '../../../utils/process';
3+
import {getGlobalVariable} from '../../../utils/env';
4+
5+
export default function() {
6+
return Promise.resolve()
7+
.then(() => process.chdir(getGlobalVariable('tmp-root')))
8+
.then(() => ng('new', 'routing-project', '--routing'))
9+
.then(() => process.chdir(path.join('routing-project')))
10+
11+
// Try to run the unit tests.
12+
.then(() => ng('test', '--single-run'));
13+
}

0 commit comments

Comments
 (0)