本文整理汇总了TypeScript中@angular/core/testing.TestComponentBuilder.overrideProviders方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestComponentBuilder.overrideProviders方法的具体用法?TypeScript TestComponentBuilder.overrideProviders怎么用?TypeScript TestComponentBuilder.overrideProviders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/core/testing.TestComponentBuilder
的用法示例。
在下文中一共展示了TestComponentBuilder.overrideProviders方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(inject(deps, fakeAsync((tcb: TestComponentBuilder) => {
builder = tcb.overrideProviders(ProjectListComponent, [
mdIconRegistryProvider,
projectServiceProvider,
routerProvider
]);
})));
示例2: async
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
tcb.overrideProviders(TestComponent, providerArr)
.createAsync(TestComponent)
.then((fixture) => {
expect(fixture.nativeElement.innerText.indexOf('HOME')).toBeTruthy();
});
})));
示例3: async
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
tcb.overrideProviders(TestComponent, providerArr)
.createAsync(TestComponent)
.then((rootTC: any) => {
let aboutDOMEl = rootTC.debugElement.children[0].nativeElement;
expect(getDOM().querySelectorAll(aboutDOMEl, 'h2')[0].textContent).toEqual('Features');
});
})));
示例4: beforeEach
beforeEach(inject(deps, fakeAsync((tcb: TestComponentBuilder) => {
builder = tcb
.overrideProviders(EmployeeNewComponent, [
disableDeprecatedForms(),
provideForms(),
employeeServiceProvider,
routerProvider
]);
})));
示例5: beforeEach
beforeEach(inject(deps, fakeAsync((tcb: TestComponentBuilder) => {
builder = tcb
.overrideProviders(NavigationComponent, [
provideRouter([], {enableTracing: true}),
identityServiceProvider,
localStorageProvider,
routerProvider
]);
})));
示例6: beforeEach
beforeEach(async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.overrideProviders(AppComponent, [
BreezeBridgeAngular2,
EntityManagerService,
provide(MetadataStoreService, {useClass: TestMetadataStoreService})
])
.createAsync(AppComponent).then(fix => {
fixture = fix;
comp = fixture.componentInstance;
});
})));
示例7: createComponent
function createComponent(tcb: TestComponentBuilder): Promise<ComponentFixture<any>> {
return tcb.overrideProviders(DemoFormWithCustomValidations, providerArr)
.createAsync(DemoFormWithCustomValidations)
.then((fixture) => {
el = fixture.debugElement.nativeElement;
input = fixture.debugElement.query(By.css("input")).nativeElement;
form = fixture.debugElement.query(By.css("form")).nativeElement;
fixture.detectChanges();
return fixture;
});
}
示例8: it
it('should do the right stuff', async(inject([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);
});
})));
示例9: async
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
tcb.overrideProviders(TestComponent, providerArr)
.createAsync(TestComponent)
.then((rootTC: any) => {
rootTC.detectChanges();
let homeInstance = rootTC.debugElement.children[0].componentInstance;
let homeDOMEl = rootTC.debugElement.children[0].nativeElement;
expect(homeInstance.nameListService).toEqual(jasmine.any(NameListService));
expect(getDOM().querySelectorAll(homeDOMEl, 'li').length).toEqual(0);
homeInstance.newName = 'Minko';
homeInstance.addName();
rootTC.detectChanges();
expect(getDOM().querySelectorAll(homeDOMEl, 'li').length).toEqual(1);
expect(getDOM().querySelectorAll(homeDOMEl, 'li')[0].textContent).toEqual('Minko');
});
})));