本文整理汇总了TypeScript中@angular/compiler/testing.ComponentFixture.whenStable方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ComponentFixture.whenStable方法的具体用法?TypeScript ComponentFixture.whenStable怎么用?TypeScript ComponentFixture.whenStable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/compiler/testing.ComponentFixture
的用法示例。
在下文中一共展示了ComponentFixture.whenStable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: expect
.createAsync(Talk).then((talk: ComponentFixture<Talk>) => {
talk.componentInstance.talk = fakeTalk;
talk.detectChanges();
talk.whenStable().then(() => {
const avatar = talk.nativeElement.querySelector('.talk .talk-speakerAvatar').getAttribute('src');
expect(avatar).toEqual(fakeTalk.speaker.avatar);
talk.destroy();
});
});
示例2: expect
builder.createAsync(WeatherWidget).then((fixture: ComponentFixture<WeatherWidget>) => {
fixture.autoDetectChanges();
fixture.debugElement.query(By.css('#w-zip')).nativeElement.value = '84111';
fixture.debugElement.query(By.css('button')).nativeElement.click();
fixture.whenStable().then((waited) => {
expect(waited).toBe(true);
expect(fixture.debugElement.query(By.css('span')).nativeElement.textContent).toEqual('70');
});
});
示例3: expect
dialog.open(PizzaMsg, config).then(dialogRef => {
viewContainerFixture.detectChanges();
let afterCloseResult: string;
dialogRef.afterClosed().subscribe(result => {
afterCloseResult = result;
});
dialogRef.close('Charmander');
viewContainerFixture.whenStable().then(() => {
expect(afterCloseResult).toBe('Charmander');
expect(overlayContainerElement.childNodes.length).toBe(0);
});
});
示例4: setTimeout
setTimeout(() => {
rootRenderer.executeCommands();
expect(mock.commandLogs.toString()).toEqual(
'CREATE+5+cmp-a+{},CREATE+6+native-text+{},CREATE+7+native-rawtext+{"text":"a"},ATTACH+6+7+0,ATTACH+5+6+0,ATTACH+3+5+1');
mock.clearLogs();
var target = fixture.elementRef.nativeElement.children[0];
fireGesture('swipe', target);
fixture.whenStable().then(() => {
rootRenderer.executeCommands();
expect(mock.commandLogs.toString()).toEqual(
'CREATE+8+cmp-b+{},CREATE+9+native-text+{},CREATE+10+native-rawtext+{"text":"b"},DETACH+3+1,ATTACH+3+8+1,ATTACH+9+10+0,ATTACH+8+9+0');
});
}, 0);
示例5: expect
.then((fixture: ComponentFixture<any>) => {
fixture.componentInstance.username._value = 'user';
fixture.componentInstance.password._value = 'pass';
fixture.detectChanges();
expect(fixture.componentInstance.username._value).toEqual('user');
expect(fixture.componentInstance.password._value).toEqual('pass');
spyOn(fixture.componentInstance, 'onReset').and.callThrough();
let button = fixture.nativeElement.querySelector('#qa-clear-button');
button.click();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(fixture.componentInstance.onReset).toHaveBeenCalled();
expect(fixture.componentInstance.username._value).toBeNull();
expect(fixture.componentInstance.password._value).toBeNull();
});
});