本文整理汇总了TypeScript中@angular/compiler/testing.ComponentFixture.autoDetectChanges方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ComponentFixture.autoDetectChanges方法的具体用法?TypeScript ComponentFixture.autoDetectChanges怎么用?TypeScript ComponentFixture.autoDetectChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/compiler/testing.ComponentFixture
的用法示例。
在下文中一共展示了ComponentFixture.autoDetectChanges方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: expect
.then((fixture: ComponentFixture<any>) => {
fixture.componentInstance.pending = true;
fixture.autoDetectChanges();
let alert = fixture.nativeElement.querySelector('#qa-pending');
expect(alert).not.toBeNull();
expect(alert.innerText).toEqual('Loading...');
});
示例2: expect
.then((fixture: ComponentFixture<any>) => {
fixture.autoDetectChanges();
let query = fixture.debugElement
.query(By.directive(RioModalContent));
expect(query).toBeTruthy();
expect(query.componentInstance).toBeTruthy();
});
示例3: expect
.then((fixture: ComponentFixture<any>) => {
fixture.autoDetectChanges();
let query = fixture.debugElement
.query(By.directive(RioLabel));
expect(query.nativeElement.querySelector('label')
.getAttribute('id')).toBe('test-1');
});
示例4: Promise
tcb.createAsync(TestComponent).then((fixture: ComponentFixture<TestComponent>) => {
fixture.autoDetectChanges();
rootRenderer.executeCommands();
expect(mock.commandLogs.toString()).toEqual('CREATE+2+test-cmp+{},CREATE+3+native-view+{},CREATE+4+router-outlet+{},ATTACH+1+2+0,ATTACH+2+3+0,ATTACH+3+4+0');
mock.clearLogs();
return new Promise((resolve: any) => {
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);
setTimeout(() => {
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');
resolve();
}, 30);
}, 0);
});
});
示例5: expect
.then((fixture: ComponentFixture<any>) => {
fixture.autoDetectChanges();
let query = fixture.debugElement
.query(By.directive(RioForm));
query.componentInstance.submit.subscribe(c => {
expect(c).toBeDefined();
});
query.nativeElement.querySelector('button').click();
});
示例6: querySelector
.then((fixture: ComponentFixture<any>) => {
fixture.componentInstance.password._touched = true;
fixture.componentInstance.password._valid = false;
fixture.autoDetectChanges();
let alert = fixture.nativeElement.
querySelector('#qa-password-validation');
expect(alert).not.toBeNull();
expect(alert.innerText).toEqual('Password is required');
});
示例7: 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');
});
});