本文整理汇总了TypeScript中@angular/core/testing.TestBed.overrideComponent方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestBed.overrideComponent方法的具体用法?TypeScript TestBed.overrideComponent怎么用?TypeScript TestBed.overrideComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/core/testing.TestBed
的用法示例。
在下文中一共展示了TestBed.overrideComponent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should throw if mdl-card-actions has no mdl-card parent', () => {
TestBed.overrideComponent(TestApp, { set: {
template: '<mdl-card-actions></mdl-card-actions>' }
});
let fixture = TestBed.createComponent(TestApp);
expect( () => fixture.detectChanges() )
.toThrow();
});
示例2: it
it('should override the template', async(() => {
TestBed.overrideComponent(GreetingComponent, {set: {
template: `<span>Foo {{greeting}}<span>`
}}).compileComponents().then(() => {
var fixture = TestBed.createComponent(GreetingComponent);
fixture.detectChanges();
var compiled = fixture.debugElement.nativeElement;
expect(compiled).toHaveText('Foo Enter PIN');
});
}));
示例3: it
it('should work in a template element', async(() => {
const template =
'<div><template [ngIf]="booleanCondition"><span>hello2</span></template></div>';
TestBed.overrideComponent(TestComponent, {set: {template: template}});
let fixture = TestBed.createComponent(TestComponent);
fixture.detectChanges();
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'span').length)
.toEqual(1);
expect(fixture.debugElement.nativeElement).toHaveText('hello2');
}));
示例4: it
it('should support string selector', () => {
TestBed.overrideComponent(
ViewChildrenStringSelectorComponent,
{set: {template: `<simple #child1></simple><simple #child2></simple>`}});
const view = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
.createComponent(ViewChildrenStringSelectorComponent);
view.detectChanges();
expect(view.componentInstance.children).toBeDefined();
expect(view.componentInstance.children.length).toBe(2);
});
示例5: it
it('should throw if an unsupported colored type is provided', () => {
TestBed.overrideComponent(MdlTestButtonComponent, { set: {
template: '<mdl-button mdl-colored="didNotExist"></mdl-button>' }
});
let fixture = TestBed.createComponent(MdlTestButtonComponent);
expect( () => fixture.detectChanges() ).toThrow();
});
示例6: createDashboardTestComponent
function createDashboardTestComponent() {
return TestBed
.overrideComponent(SkyTileDashboardComponent, {
add: {
providers: [
{provide: SkyMediaQueryService, useValue: mockMediaQueryService}
]
}
})
.createComponent(TileDashboardTestComponent);
}
示例7: beforeEach
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [TestAlertComponent],
imports: [AlertModule.forRoot()]
});
TestBed.overrideComponent(TestAlertComponent, {
set: {template: overTemplate}
});
fixture = TestBed.createComponent(TestAlertComponent);
context = fixture.debugElement.componentInstance;
fixture.detectChanges();
});
示例8: it
it('should add the css class mdl-layout__tab-panel to the host element', () => {
TestBed.overrideComponent(MdlTestComponent, { set: {
template: '<mdl-layout-tab-panel>x</mdl-layout-tab-panel>' }
});
let fixture = TestBed.createComponent(MdlTestComponent);
fixture.detectChanges();
let tabPanelEl: HTMLElement = fixture.nativeElement.children.item(0);
expect(tabPanelEl.classList.contains('mdl-layout__tab-panel')).toBe(true);
});
示例9: it
it('should render all components', () => {
TestBed.overrideComponent(TestContainerComponent, {
set: {
template: `
${componentNames.map((name) => `<dx-${name}></dx-${name}>`).join('')}
`
}
});
let fixture = TestBed.createComponent(TestContainerComponent);
expect(fixture.detectChanges.bind(fixture)).not.toThrow();
});
示例10: it
it("it should ...", async(() => {
TestBed.overrideComponent(BarGraphDirective, {set: {
template: "<p>Content</p>"
}});
TestBed.compileComponents().then(() => {
let fixture = TestBed.createComponent(BarGraphDirective);
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(fixture).toBeTruthy();
});
}));