本文整理汇总了TypeScript中@angular/compiler/testing.TestComponentBuilder.overrideView方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestComponentBuilder.overrideView方法的具体用法?TypeScript TestComponentBuilder.overrideView怎么用?TypeScript TestComponentBuilder.overrideView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/compiler/testing.TestComponentBuilder
的用法示例。
在下文中一共展示了TestComponentBuilder.overrideView方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: inject
inject([TestComponentBuilder, Log, AsyncTestCompleter], (tcb: TestComponentBuilder, log: Log,
async: any /** TODO #9100 */) => {
tcb.overrideView(
MyComp5,
new ViewMetadata(
{template: '<div [field]="123" lifecycle></div>', directives: [LifecycleCmp]}))
.createAsync(MyComp5)
.then((tc) => {
tc.detectChanges();
expect(log.result())
.toEqual(
"ngOnChanges; ngOnInit; ngDoCheck; ngAfterContentInit; ngAfterContentChecked; child_ngDoCheck; " +
"ngAfterViewInit; ngAfterViewChecked");
log.clear();
tc.detectChanges();
expect(log.result())
.toEqual(
"ngDoCheck; ngAfterContentChecked; child_ngDoCheck; ngAfterViewChecked");
async.done();
});
}));
示例2: ViewMetadata
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp1, new ViewMetadata({template: `{{!null?.length}}`}))
.createAsync(MyComp1)
.then((fixture) => {
fixture.detectChanges();
expect(fixture.nativeElement).toHaveText('true');
async.done();
});
}));
示例3: inject
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp1,
new ViewMetadata({template: `{{'red' + (true ? ' border' : '')}}`}))
.createAsync(MyComp1)
.then((fixture) => {
fixture.detectChanges();
expect(fixture.nativeElement).toHaveText('red border');
async.done();
});
}));
示例4: ViewMetadata
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(
ViewChildStringSelectorComponent,
new ViewMetadata({template: `<simple #child></simple>`, directives: [Simple]}))
.createAsync(ViewChildStringSelectorComponent)
.then((view) => {
view.detectChanges();
expect(view.componentInstance.child).toBeDefined();
async.done();
});
}));
示例5: inject
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(ViewChildrenTypeSelectorComponent,
new ViewMetadata({template: `<simple></simple><simple></simple>`, directives: [Simple]}))
.createAsync(ViewChildrenTypeSelectorComponent)
.then((view) => {
view.detectChanges();
expect(view.componentInstance.children).toBeDefined();
expect(view.componentInstance.children.length).toBe(2);
async.done();
});
}));
示例6: inject
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
tcb.overrideView(ViewChildTypeSelectorComponent,
new ViewMetadata(
{template: `<simple [marker]="'1'"></simple><simple [marker]="'2'"></simple>`, directives: [Simple]}))
.createAsync(ViewChildTypeSelectorComponent)
.then((view) => {
view.detectChanges();
expect(view.componentInstance.child).toBeDefined();
expect(view.componentInstance.child.marker).toBe("1");
async.done();
});
}));