From 90b3285fbe2604370c198862c9e1f0e0a9be7839 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 27 Sep 2018 12:37:21 +0200 Subject: [PATCH 1/2] style: improve formatting of spec file --- .../angular/application/other-files/app.component.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/schematics/angular/application/other-files/app.component.spec.ts b/packages/schematics/angular/application/other-files/app.component.spec.ts index b6a0247dcd8a..0e7f901ad12d 100644 --- a/packages/schematics/angular/application/other-files/app.component.spec.ts +++ b/packages/schematics/angular/application/other-files/app.component.spec.ts @@ -1,6 +1,7 @@ import { TestBed, async } from '@angular/core/testing';<% if (routing) { %> import { RouterTestingModule } from '@angular/router/testing';<% } %> import { AppComponent } from './app.component'; + describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({<% if (routing) { %> @@ -12,16 +13,19 @@ describe('AppComponent', () => { ], }).compileComponents(); })); + it('should create the app', async(() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); })); + it(`should have as title '<%= name %>'`, async(() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app.title).toEqual('<%= name %>'); })); + it('should render title in a h1 tag', async(() => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); From 4bb91cf68770b9209f2727513abd2dcc4b62e13d Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 27 Sep 2018 13:30:37 +0200 Subject: [PATCH 2/2] style: remove redundant `async` in tests In component specs only the `compileComponents` is async thus the `async` on `it` are redudnant Closes #12161 --- .../application/other-files/app.component.spec.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/schematics/angular/application/other-files/app.component.spec.ts b/packages/schematics/angular/application/other-files/app.component.spec.ts index 0e7f901ad12d..23a395040bf2 100644 --- a/packages/schematics/angular/application/other-files/app.component.spec.ts +++ b/packages/schematics/angular/application/other-files/app.component.spec.ts @@ -1,7 +1,7 @@ import { TestBed, async } from '@angular/core/testing';<% if (routing) { %> import { RouterTestingModule } from '@angular/router/testing';<% } %> import { AppComponent } from './app.component'; - + describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({<% if (routing) { %> @@ -14,22 +14,22 @@ describe('AppComponent', () => { }).compileComponents(); })); - it('should create the app', async(() => { + it('should create the app', () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); - })); + }); - it(`should have as title '<%= name %>'`, async(() => { + it(`should have as title '<%= name %>'`, () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app.title).toEqual('<%= name %>'); - })); + }); - it('should render title in a h1 tag', async(() => { + it('should render title in a h1 tag', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('h1').textContent).toContain('Welcome to <%= name %>!'); - })); + }); });