当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TestComponentBuilder.overrideView方法代码示例

本文整理汇总了TypeScript中@angular/core/testing.TestComponentBuilder.overrideView方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestComponentBuilder.overrideView方法的具体用法?TypeScript TestComponentBuilder.overrideView怎么用?TypeScript TestComponentBuilder.overrideView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/core/testing.TestComponentBuilder的用法示例。


在下文中一共展示了TestComponentBuilder.overrideView方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: fakeAsync

         fakeAsync(() => {
           xhr.spy('get').andCallFake(() => Promise.resolve('init'));
           let compFixture =
               tcb.overrideView(SomeComp, new ViewMetadata({templateUrl: '/myComp.html'}))
                   .createFakeAsync(SomeComp);
           expect(compFixture.nativeElement).toHaveText('init');

           xhr.spy('get').andCallFake(() => Promise.resolve('new content'));
           // Note: overrideView is calling .clearCacheFor...
           compFixture = tcb.overrideView(SomeComp, new ViewMetadata({templateUrl: '/myComp.html'}))
                             .createFakeAsync(SomeComp);
           expect(compFixture.nativeElement).toHaveText('new content');
         }));
开发者ID:4vanger,项目名称:angular,代码行数:13,代码来源:runtime_compiler_spec.ts

示例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();
       });
 }));
开发者ID:HongXG,项目名称:angular,代码行数:9,代码来源:regression_integration_spec.ts

示例3: ViewMetadata

 () => {
   xhr.spy('get').andCallFake(() => Promise.resolve(''));
   let localTcb =
       tcb.overrideView(SomeComp, new ViewMetadata({template: '', directives: [ChildComp]}))
           .overrideView(ChildComp, new ViewMetadata({templateUrl: '/someTpl.html'}));
   expect(() => localTcb.createSync(SomeComp))
       .toThrowError(
           `Can't compile synchronously as ${stringify(ChildComp)} is still being loaded!`);
 });
开发者ID:4vanger,项目名称:angular,代码行数:9,代码来源:runtime_compiler_spec.ts

示例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();
       });
 }));
开发者ID:AngularLovers,项目名称:angular,代码行数:11,代码来源:di_spec.ts

示例5: inject

 inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
   const compFixture = tcb.overrideView(MainComp, new ViewMetadata({
                                          template: '<child><nested></nested></child>',
                                          directives: [ChildComp, NestedChildComp]
                                        }))
                           .overrideTemplate(ChildComp, '<ng-content></ng-content>')
                           .createSync(MainComp);
   let nestedChildCompEl = compFixture.debugElement.children[0].children[0];
   let nestedChildComp: NestedChildComp = nestedChildCompEl.componentInstance;
   expect(nestedChildComp.cfr.resolveComponentFactory(ChildComp).componentType)
       .toBe(ChildComp);
   expect(() => nestedChildComp.cfr.resolveComponentFactory(NestedChildComp))
       .toThrow(new NoComponentFactoryError(NestedChildComp));
 }));
开发者ID:alexbell1,项目名称:angular,代码行数:14,代码来源:precompile_integration_spec.ts

示例6: ViewMetadata

           (tcb: TestComponentBuilder, log: Log, async: AsyncTestCompleter) => {
             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();
                 });
           }));
开发者ID:AngularLovers,项目名称:angular,代码行数:24,代码来源:directive_lifecycle_integration_spec.ts


注:本文中的@angular/core/testing.TestComponentBuilder.overrideView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。