本文整理匯總了TypeScript中angular2/testing_internal.TestComponentBuilder.createAsync方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestComponentBuilder.createAsync方法的具體用法?TypeScript TestComponentBuilder.createAsync怎麽用?TypeScript TestComponentBuilder.createAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular2/testing_internal.TestComponentBuilder
的用法示例。
在下文中一共展示了TestComponentBuilder.createAsync方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: inject
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(HomeComponent).then((fixture) => {
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h2').textContent).toEqual('Home!');
async.done();
});
}));
示例2: inject
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
tcb.createAsync(AppCmp).then((fixture) => {
var router = fixture.debugElement.componentInstance.router;
PromiseWrapper.catchError(router.navigateByUrl('/cause-error'), (error) => {
expect(error).toContainError('oops!');
async.done();
});
});
}));
示例3: fakeAsync
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
let fixture: ComponentFixture;
tcb.createAsync(TestComponent).then((f) => { fixture = f; });
// This should initialize the fixture.
tick();
expect(fixture.debugElement.children[0].nativeElement).toHaveText('Hello');
})));
示例4: inject
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
tcb.createAsync(AppCmp).then((rootTC) => {
var router = rootTC.debugElement.componentInstance.router;
PromiseWrapper.catchError(router.navigateByUrl('/cause-error'), (error) => {
expect(rootTC.debugElement.nativeElement).toHaveText('outer { oh no }');
expect(error).toContainError('oops!');
async.done();
});
});
}));
示例5: inject
inject([AsyncTestCompleter, Router], (async, router) => {
tcb.createAsync(TestComponent).then((testComponent) => {
testComponent.detectChanges();
testComponent.debugElement.query(By.css('a.detail-view-blank'))
.triggerEventHandler('click', null);
expect(router.spy('navigateByInstruction')).not.toHaveBeenCalled();
async.done();
});
}));
示例6: it
it('should update a[href] attribute', inject([AsyncTestCompleter], (async) => {
tcb.createAsync(TestComponent).then((testComponent) => {
testComponent.detectChanges();
let anchorElement =
testComponent.debugElement.query(By.css('a.detail-view')).nativeElement;
expect(DOM.getAttribute(anchorElement, 'href')).toEqual('detail');
async.done();
});
}));
示例7: inject
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(TestComp).then((fixture) => {
let mutable: number[] = [1, 2];
fixture.debugElement.componentInstance.data = mutable;
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('2');
mutable.push(3);
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('2,3');
async.done();
});
}));