Skip to content

Commit daacb00

Browse files
Merge pull request #511 from angular/master
Compare changes across branches, commits, tags, and more below.
2 parents 4b0c880 + 8fbf40b commit daacb00

File tree

81 files changed

+1394
-1399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1394
-1399
lines changed

.bazelrc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,6 @@ build:remote --remote_executor=remotebuildexecution.googleapis.com
136136
# retry mechanism and we do not want to retry unnecessarily if Karma already tried multiple times.
137137
test:saucelabs --flaky_test_attempts=1
138138

139-
###############################
140-
# NodeJS rules settings
141-
# These settings are required for rules_nodejs
142-
###############################
143-
144-
# Turn on managed directories feature in Bazel
145-
# This allows us to avoid installing a second copy of node_modules
146-
common --experimental_allow_incremental_repository_updates
147-
148139
####################################################
149140
# User bazel configuration
150141
# NOTE: This needs to be the *last* entry in the config.
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
import { TestBed, async } from '@angular/core/testing';
1+
import { TestBed, waitForAsync } from '@angular/core/testing';
2+
23
import { AppComponent } from './app.component';
3-
import { TemplateModule } from './template/template.module';
44
import { ReactiveModule } from './reactive/reactive.module';
5+
import { TemplateModule } from './template/template.module';
56

67
describe('AppComponent', () => {
7-
8-
beforeEach(async(() => {
9-
TestBed.configureTestingModule({
10-
imports: [ReactiveModule, TemplateModule],
11-
declarations: [
12-
AppComponent
13-
],
14-
}).compileComponents();
8+
beforeEach(waitForAsync(() => {
9+
TestBed
10+
.configureTestingModule({
11+
imports: [ReactiveModule, TemplateModule],
12+
declarations: [AppComponent],
13+
})
14+
.compileComponents();
1515
}));
1616

17-
it('should create the app', async(() => {
18-
const fixture = TestBed.createComponent(AppComponent);
19-
const app = fixture.componentInstance;
17+
it('should create the app', waitForAsync(() => {
18+
const fixture = TestBed.createComponent(AppComponent);
19+
const app = fixture.componentInstance;
2020

21-
expect(app).toBeTruthy();
22-
}));
21+
expect(app).toBeTruthy();
22+
}));
2323

24-
it('should render title', async(() => {
25-
const fixture = TestBed.createComponent(AppComponent);
26-
fixture.detectChanges();
24+
it('should render title', waitForAsync(() => {
25+
const fixture = TestBed.createComponent(AppComponent);
26+
fixture.detectChanges();
2727

28-
const compiled = fixture.debugElement.nativeElement;
29-
expect(compiled.querySelector('h1').textContent).toContain('Forms Overview');
30-
}));
28+
const compiled = fixture.debugElement.nativeElement;
29+
expect(compiled.querySelector('h1').textContent).toContain('Forms Overview');
30+
}));
3131
});

aio/content/examples/forms-overview/src/app/reactive/favorite-color/favorite-color.component.spec.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
1+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
22
import { ReactiveFormsModule } from '@angular/forms';
33

4-
import { FavoriteColorComponent } from './favorite-color.component';
54
import { createNewEvent } from '../../shared/utils';
5+
import { FavoriteColorComponent } from './favorite-color.component';
66

77
describe('Favorite Color Component', () => {
88
let component: FavoriteColorComponent;
99
let fixture: ComponentFixture<FavoriteColorComponent>;
1010

11-
beforeEach(async(() => {
12-
TestBed.configureTestingModule({
13-
imports: [ ReactiveFormsModule ],
14-
declarations: [ FavoriteColorComponent ]
15-
})
16-
.compileComponents();
11+
beforeEach(waitForAsync(() => {
12+
TestBed
13+
.configureTestingModule(
14+
{imports: [ReactiveFormsModule], declarations: [FavoriteColorComponent]})
15+
.compileComponents();
1716
}));
1817

1918
beforeEach(() => {
Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import { async, ComponentFixture, TestBed, tick, fakeAsync } from '@angular/core/testing';
1+
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
22
import { FormsModule } from '@angular/forms';
33

4-
import { FavoriteColorComponent } from './favorite-color.component';
54
import { createNewEvent } from '../../shared/utils';
5+
import { FavoriteColorComponent } from './favorite-color.component';
66

77
describe('FavoriteColorComponent', () => {
88
let component: FavoriteColorComponent;
99
let fixture: ComponentFixture<FavoriteColorComponent>;
1010

11-
beforeEach(async(() => {
12-
TestBed.configureTestingModule({
13-
imports: [ FormsModule ],
14-
declarations: [ FavoriteColorComponent ]
15-
})
16-
.compileComponents();
11+
beforeEach(waitForAsync(() => {
12+
TestBed.configureTestingModule({imports: [FormsModule], declarations: [FavoriteColorComponent]})
13+
.compileComponents();
1714
}));
1815

1916
beforeEach(() => {
@@ -28,29 +25,29 @@ describe('FavoriteColorComponent', () => {
2825

2926
// #docregion model-to-view
3027
it('should update the favorite color on the input field', fakeAsync(() => {
31-
component.favoriteColor = 'Blue';
28+
component.favoriteColor = 'Blue';
3229

33-
fixture.detectChanges();
30+
fixture.detectChanges();
3431

35-
tick();
32+
tick();
3633

37-
const input = fixture.nativeElement.querySelector('input');
34+
const input = fixture.nativeElement.querySelector('input');
3835

39-
expect(input.value).toBe('Blue');
40-
}));
36+
expect(input.value).toBe('Blue');
37+
}));
4138
// #enddocregion model-to-view
4239

4340
// #docregion view-to-model
4441
it('should update the favorite color in the component', fakeAsync(() => {
45-
const input = fixture.nativeElement.querySelector('input');
46-
const event = createNewEvent('input');
42+
const input = fixture.nativeElement.querySelector('input');
43+
const event = createNewEvent('input');
4744

48-
input.value = 'Red';
49-
input.dispatchEvent(event);
45+
input.value = 'Red';
46+
input.dispatchEvent(event);
5047

51-
fixture.detectChanges();
48+
fixture.detectChanges();
5249

53-
expect(component.favoriteColor).toEqual('Red');
54-
}));
50+
expect(component.favoriteColor).toEqual('Red');
51+
}));
5552
// #enddocregion view-to-model
5653
});

aio/content/examples/schematics-for-libraries/projects/my-lib/src/lib/my-lib.component.spec.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
1+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
22

33
import { MyLibComponent } from './my-lib.component';
44

55
describe('MyLibComponent', () => {
66
let component: MyLibComponent;
77
let fixture: ComponentFixture<MyLibComponent>;
88

9-
beforeEach(async(() => {
10-
TestBed.configureTestingModule({
11-
declarations: [ MyLibComponent ]
12-
})
13-
.compileComponents();
9+
beforeEach(waitForAsync(() => {
10+
TestBed.configureTestingModule({declarations: [MyLibComponent]}).compileComponents();
1411
}));
1512

1613
beforeEach(() => {
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import { AppComponent } from './app.component';
2-
3-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
4-
import { By } from '@angular/platform-browser';
51
import { DebugElement } from '@angular/core';
2+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
3+
import { By } from '@angular/platform-browser';
4+
5+
import { AppComponent } from './app.component';
66

77
describe('AppComponent', () => {
88
let de: DebugElement;
99
let comp: AppComponent;
1010
let fixture: ComponentFixture<AppComponent>;
1111

12-
beforeEach(async(() => {
13-
TestBed.configureTestingModule({
14-
declarations: [ AppComponent ]
15-
})
16-
.compileComponents();
12+
beforeEach(waitForAsync(() => {
13+
TestBed.configureTestingModule({declarations: [AppComponent]}).compileComponents();
1714
}));
1815

1916
beforeEach(() => {
@@ -22,12 +19,11 @@ describe('AppComponent', () => {
2219
de = fixture.debugElement.query(By.css('h1'));
2320
});
2421

25-
it('should create component', () => expect(comp).toBeDefined() );
22+
it('should create component', () => expect(comp).toBeDefined());
2623

2724
it('should have expected <h1> text', () => {
2825
fixture.detectChanges();
2926
const h1 = de.nativeElement;
30-
expect(h1.textContent).toMatch(/angular/i,
31-
'<h1> should say something about "Angular"');
27+
expect(h1.textContent).toMatch(/angular/i, '<h1> should say something about "Angular"');
3228
});
3329
});
Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #docplaster
22
// #docregion
3-
import { TestBed, async } from '@angular/core/testing';
3+
import { TestBed, waitForAsync } from '@angular/core/testing';
44
// #enddocregion
55
import { AppComponent } from './app-initial.component';
66
/*
@@ -12,29 +12,29 @@ describe('AppComponent', () => {
1212
*/
1313
describe('AppComponent (initial CLI version)', () => {
1414
// #docregion
15-
beforeEach(async(() => {
16-
TestBed.configureTestingModule({
17-
declarations: [
18-
AppComponent
19-
],
20-
}).compileComponents();
21-
}));
22-
it('should create the app', async(() => {
23-
const fixture = TestBed.createComponent(AppComponent);
24-
const app = fixture.componentInstance;
25-
expect(app).toBeTruthy();
26-
}));
27-
it(`should have as title 'app'`, async(() => {
28-
const fixture = TestBed.createComponent(AppComponent);
29-
const app = fixture.componentInstance;
30-
expect(app.title).toEqual('app');
31-
}));
32-
it('should render title', async(() => {
33-
const fixture = TestBed.createComponent(AppComponent);
34-
fixture.detectChanges();
35-
const compiled = fixture.nativeElement;
36-
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
15+
beforeEach(waitForAsync(() => {
16+
TestBed
17+
.configureTestingModule({
18+
declarations: [AppComponent],
19+
})
20+
.compileComponents();
3721
}));
22+
it('should create the app', waitForAsync(() => {
23+
const fixture = TestBed.createComponent(AppComponent);
24+
const app = fixture.componentInstance;
25+
expect(app).toBeTruthy();
26+
}));
27+
it(`should have as title 'app'`, waitForAsync(() => {
28+
const fixture = TestBed.createComponent(AppComponent);
29+
const app = fixture.componentInstance;
30+
expect(app.title).toEqual('app');
31+
}));
32+
it('should render title', waitForAsync(() => {
33+
const fixture = TestBed.createComponent(AppComponent);
34+
fixture.detectChanges();
35+
const compiled = fixture.nativeElement;
36+
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
37+
}));
3838
});
3939
// #enddocregion
4040

@@ -43,16 +43,13 @@ import { DebugElement } from '@angular/core';
4343
import { ComponentFixture } from '@angular/core/testing';
4444

4545
describe('AppComponent (initial CLI version - as it should be)', () => {
46-
4746
let app: AppComponent;
4847
let de: DebugElement;
4948
let fixture: ComponentFixture<AppComponent>;
5049

5150
beforeEach(() => {
5251
TestBed.configureTestingModule({
53-
declarations: [
54-
AppComponent
55-
],
52+
declarations: [AppComponent],
5653
});
5754

5855
fixture = TestBed.createComponent(AppComponent);
@@ -70,7 +67,6 @@ describe('AppComponent (initial CLI version - as it should be)', () => {
7067

7168
it('should render title in an h1 tag', () => {
7269
fixture.detectChanges();
73-
expect(de.nativeElement.querySelector('h1').textContent)
74-
.toContain('Welcome to app!');
70+
expect(de.nativeElement.querySelector('h1').textContent).toContain('Welcome to app!');
7571
});
7672
});

0 commit comments

Comments
 (0)