本文整理汇总了TypeScript中@angular/compiler/testing.TestComponentBuilder.overrideProviders方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestComponentBuilder.overrideProviders方法的具体用法?TypeScript TestComponentBuilder.overrideProviders怎么用?TypeScript TestComponentBuilder.overrideProviders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/compiler/testing.TestComponentBuilder
的用法示例。
在下文中一共展示了TestComponentBuilder.overrideProviders方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
async(inject([TestComponentBuilder], (tcb:TestComponentBuilder) => {
tcb.overrideProviders(TestComponent, providerArr)
.createAsync(TestComponent)
.then((fixture) => {
expect(fixture.nativeElement.innerText.indexOf('HOME')).toBeTruthy();
});
})));
示例2: async
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
tcb.overrideProviders(TestComponent, providerArr)
.createAsync(TestComponent)
.then((fixture) => {
expect(true).toBeTruthy();
});
})));
示例3: 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);
spyOn(homeInstance.nameListService, 'add').and.callFake((name) => {
homeInstance.nameList.push(name);
});
homeInstance.newName = 'Minko';
homeInstance.addName();
rootTC.detectChanges();
expect(getDOM().querySelectorAll(homeDOMEl, 'li').length).toEqual(1);
expect(getDOM().querySelectorAll(homeDOMEl, 'li')[0].textContent).toEqual('Minko');
});
})));
示例4: it
it('should initialize displaying a specific task', done => {
// We mock the TaskService provider with some fake data
let mockTaskService = {
taskStore: [{
name: 'Task A'
}, {
name: 'Task B'
}, {
name: 'Task C'
}
]
};
testComponentBuilder
.overrideProviders(TimerWidgetComponent, [
provide(RouteParams, { useValue: new RouteParams({ id: '1' }) }),
provide(TaskService, { useValue: mockTaskService })
])
.createAsync(TimerWidgetComponent)
.then(componentFixture => {
componentFixture.componentInstance.ngOnInit();
componentFixture.detectChanges();
expect(componentFixture.componentInstance.taskName).toEqual('Task B');
expect(componentFixture.nativeElement.querySelector('small')).toHaveText('Task B');
componentFixture.destroy();
done();
})
.catch(e => done.fail(e));
});
示例5: inject
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb
.overrideProviders(AlfrescoSearchComponent, [
{ provide: AlfrescoSearchService, useClass: SearchServiceMock }
])
.createAsync(AlfrescoSearchComponent)
.then((fixture) => {
let componentInstance = fixture.componentInstance;
componentInstance.results = [{
entry: {
id: '123',
name: 'MyDoc',
content: {
mimetype: 'text/plain'
},
isFile: true
}
}];
fixture.detectChanges(componentInstance.results[0]);
componentInstance.preview.subscribe(e => {
expect(e.value).toBe(componentInstance.results[0]);
});
componentInstance.onItemClick();
});
}));
示例6: 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');
});
})));
示例7: async
async(inject([TestComponentBuilder], (tcb:TestComponentBuilder) => {
tcb.overrideProviders(TestComponent, providerArr)
.createAsync(TestComponent)
.then((rootTC:any) => {
let forgotDOMEl = rootTC.debugElement.children[0].nativeElement;
expect(getDOM().querySelectorAll(forgotDOMEl, 'h3')[0].textContent)
.toEqual('Enter your email address to receive a reminder email.');
});
})));
示例8: it
it('should create the component', inject([], () => {
return builder
.overrideProviders(SignUpComponent, [authenticationServiceProviderMock])
.overrideDirective(SignUpComponent, MessageComponent, EmptyComponent)
.createAsync(SignUpComponentTestController)
.then((fixture: ComponentFixture<any>) => {
let query = fixture.debugElement.query(By.directive(SignUpComponent));
expect(query).toBeTruthy();
expect(query.componentInstance).toBeTruthy();
});
}));
示例9: spyOn
(tcb: TestComponentBuilder) => {
spyOn(service, 'list').and.returnValue(Observable.of([
{name: 'Lyon'},
{name: 'Los Angeles'},
{name: 'Sidney'},
{name: 'Tokyo'},
{name: 'Casablanca'}
]));
return tcb.overrideProviders(RacesComponent, [provide(RaceService, {useValue: service})])
.createAsync(RacesComponent)
.then(f => fixture = f);
}
示例10: async
return async(inject([TestComponentBuilder], (tcb:TestComponentBuilder) => {
tcb
.overrideProviders(FollowBtnComponent, [
{provide: FollowBtnService, useValue: followBtnService}
])
.createAsync(TestComponent)
.then((fixture:ComponentFixture<any>) => {
testCmpDebugElement = fixture.debugElement;
cmpDebugElement = testCmpDebugElement.query(By.directive(FollowBtnComponent));
fixture.detectChanges();
});
}));