Skip to content
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

fix(new): include routing in spec and inline template when called with --routing #3252

Merged
merged 3 commits into from
Dec 1, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
/* tslint:disable:no-unused-variable */

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

describe('AppComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
TestBed.configureTestingModule({<% if (routing) { %>
imports: [
RouterTestingModule
],<% } %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're fixing this, can you add a compileComponents call in here as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

declarations: [
AppComponent
],
});
TestBed.compileComponents();
});

it('should create the app', async(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { APP_SHELL_DIRECTIVES } from '@angular/app-shell';<% } %>
template: `
<h1>
{{title}}
</h1>
</h1><% if (routing) { %>
<router-outlet></router-outlet><% } %>
`,<% } else { %>
templateUrl: './app.component.html',<% } %><% if (inlineStyle) { %>
styles: []<% } else { %>
Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/tests/commands/new/new-routing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as path from 'path';
import {ng} from '../../../utils/process';
import {getGlobalVariable} from '../../../utils/env';

export default function() {
return Promise.resolve()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You seem to overly complicate how this test could work. Why not:

return return Promise.resolve()
  .then(() => process.chdir(getGlobalVariable('tmp-root')))
  .then(() => ng('new', 'routing-project', '--routing'))
  .then(() => process.chdir(path.join('routing-project')))
  .then(() => ng('test', '--single-run'));

The only thing missing would be to chdir back to the directory we were in before this test, but really e2e_runner should take care of that (and I'm going to do a PR for it).

We already work off a temporary directory, there's no need to clean up after yourself :) This is by design.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#3287 will fix the chdir.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You keep showing me awesome gems. I didn't realise the getGlobalVariable() before!

Will update tomorrow or today if I have time.

.then(() => process.chdir(getGlobalVariable('tmp-root')))
.then(() => ng('new', 'routing-project', '--routing'))
.then(() => process.chdir(path.join('routing-project')))

// Try to run the unit tests.
.then(() => ng('test', '--single-run'));
}