本文整理匯總了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();
});
}));