feat(core): update reference and doc to change async
to waitAsync
. (#37583)
The last commit change `async` to `waitForAsync`. This commit update all usages in the code and also update aio doc. PR Close #37583
This commit is contained in:

committed by
Alex Rickabaugh

parent
8f074296c2
commit
8fbf40bf40
@ -1,31 +1,31 @@
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { TestBed, waitForAsync } from '@angular/core/testing';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { TemplateModule } from './template/template.module';
|
||||
import { ReactiveModule } from './reactive/reactive.module';
|
||||
import { TemplateModule } from './template/template.module';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ReactiveModule, TemplateModule],
|
||||
declarations: [
|
||||
AppComponent
|
||||
],
|
||||
}).compileComponents();
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed
|
||||
.configureTestingModule({
|
||||
imports: [ReactiveModule, TemplateModule],
|
||||
declarations: [AppComponent],
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
it('should create the app', async(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
it('should create the app', waitForAsync(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
|
||||
expect(app).toBeTruthy();
|
||||
}));
|
||||
expect(app).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should render title', async(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
it('should render title', waitForAsync(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
expect(compiled.querySelector('h1').textContent).toContain('Forms Overview');
|
||||
}));
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
expect(compiled.querySelector('h1').textContent).toContain('Forms Overview');
|
||||
}));
|
||||
});
|
||||
|
@ -1,19 +1,18 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
import { FavoriteColorComponent } from './favorite-color.component';
|
||||
import { createNewEvent } from '../../shared/utils';
|
||||
import { FavoriteColorComponent } from './favorite-color.component';
|
||||
|
||||
describe('Favorite Color Component', () => {
|
||||
let component: FavoriteColorComponent;
|
||||
let fixture: ComponentFixture<FavoriteColorComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ ReactiveFormsModule ],
|
||||
declarations: [ FavoriteColorComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed
|
||||
.configureTestingModule(
|
||||
{imports: [ReactiveFormsModule], declarations: [FavoriteColorComponent]})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -1,19 +1,16 @@
|
||||
import { async, ComponentFixture, TestBed, tick, fakeAsync } from '@angular/core/testing';
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import { FavoriteColorComponent } from './favorite-color.component';
|
||||
import { createNewEvent } from '../../shared/utils';
|
||||
import { FavoriteColorComponent } from './favorite-color.component';
|
||||
|
||||
describe('FavoriteColorComponent', () => {
|
||||
let component: FavoriteColorComponent;
|
||||
let fixture: ComponentFixture<FavoriteColorComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ FormsModule ],
|
||||
declarations: [ FavoriteColorComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({imports: [FormsModule], declarations: [FavoriteColorComponent]})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
@ -28,29 +25,29 @@ describe('FavoriteColorComponent', () => {
|
||||
|
||||
// #docregion model-to-view
|
||||
it('should update the favorite color on the input field', fakeAsync(() => {
|
||||
component.favoriteColor = 'Blue';
|
||||
component.favoriteColor = 'Blue';
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
tick();
|
||||
tick();
|
||||
|
||||
const input = fixture.nativeElement.querySelector('input');
|
||||
const input = fixture.nativeElement.querySelector('input');
|
||||
|
||||
expect(input.value).toBe('Blue');
|
||||
}));
|
||||
expect(input.value).toBe('Blue');
|
||||
}));
|
||||
// #enddocregion model-to-view
|
||||
|
||||
// #docregion view-to-model
|
||||
it('should update the favorite color in the component', fakeAsync(() => {
|
||||
const input = fixture.nativeElement.querySelector('input');
|
||||
const event = createNewEvent('input');
|
||||
const input = fixture.nativeElement.querySelector('input');
|
||||
const event = createNewEvent('input');
|
||||
|
||||
input.value = 'Red';
|
||||
input.dispatchEvent(event);
|
||||
input.value = 'Red';
|
||||
input.dispatchEvent(event);
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.favoriteColor).toEqual('Red');
|
||||
}));
|
||||
expect(component.favoriteColor).toEqual('Red');
|
||||
}));
|
||||
// #enddocregion view-to-model
|
||||
});
|
||||
|
Reference in New Issue
Block a user