本文整理汇总了TypeScript中angular2/testing.TestComponentBuilder.overrideProviders方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestComponentBuilder.overrideProviders方法的具体用法?TypeScript TestComponentBuilder.overrideProviders怎么用?TypeScript TestComponentBuilder.overrideProviders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/testing.TestComponentBuilder
的用法示例。
在下文中一共展示了TestComponentBuilder.overrideProviders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: injectAsync
injectAsync([ TestComponentBuilder ], (tcb: TestComponentBuilder) => {
return tcb.overrideProviders(AppComponent, ROUTER_PROVIDERS)
.createAsync(AppComponent)
.then(fixture => {
expect(fixture.nativeElement.textContent).toBe('Hello!');
});
}));
示例2: beforeEach
beforeEach(injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.overrideProviders(AppComponent, [
Angular2Bridge,
EntityManagerService,
provide(MetadataStoreService, {useClass: TestMetadataStoreService})
])
.createAsync(AppComponent).then(fix => {
fixture = fix;
comp = fixture.componentInstance;
});
}));
示例3: createComponent
function createComponent(tcb: TestComponentBuilder): Promise<ComponentFixture> {
return tcb
.overrideProviders(CreateUserComponent, [provide(UserService, {useClass: MockUserService})])
.createAsync(CreateUserComponent)
.then((fixture: ComponentFixture) => {
element = fixture.debugElement.nativeElement;
form = fixture.debugElement.query(By.css('form')).nativeElement;
usernameInput = fixture.debugElement.query(By.css('#username')).nativeElement;
emailInput = fixture.debugElement.query(By.css('#email')).nativeElement;
fixture.detectChanges();
return fixture;
});
}
示例4: it
it('should do the right stuff', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.overrideProviders(TodoCmp, [provide(TodoService, {useClass: MockTodoService})]).createAsync(TodoCmp).then((fixture) => {
fixture.detectChanges();
let instance = fixture.debugElement.componentInstance;
expect(instance.todoList.length).toBe(0);
instance.add(1);
expect(instance.todoList.length).toBe(1);
});
}));