當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。