• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript testing_internal.TestComponentBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中angular2/testing_internal.TestComponentBuilder的典型用法代码示例。如果您正苦于以下问题:TypeScript TestComponentBuilder类的具体用法?TypeScript TestComponentBuilder怎么用?TypeScript TestComponentBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: inject

         inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';

           tcb.overrideTemplate(TestComponent, html)
               .createAsync(TestComponent)
               .then((fixture) => {
                 fixture.detectChanges();
                 expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
                     .toEqual(1);
                 expect(fixture.debugElement.nativeElement).toHaveText('hello');

                 fixture.debugElement.componentInstance.numberCondition = 2;
                 fixture.detectChanges();
                 expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
                     .toEqual(1);
                 expect(fixture.debugElement.nativeElement).toHaveText('hello');

                 async.done();
               });
         }));
开发者ID:TedSander,项目名称:angular,代码行数:20,代码来源:ng_if_spec.ts


示例2: inject

       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
         var template = `<tpl-refs #refs="tplRefs"><template>foo</template><template>bar</template></tpl-refs><template [ngTemplateOutlet]="currentTplRef"></template>`;
         tcb.overrideTemplate(TestComponent, template)
             .createAsync(TestComponent)
             .then((fixture) => {

               fixture.detectChanges();
               var refs = fixture.debugElement.children[0].getLocal('refs');

               fixture.componentInstance.currentTplRef = refs.tplRefs.first;
               fixture.detectChanges();
               expect(fixture.nativeElement).toHaveText('foo');

               fixture.componentInstance.currentTplRef = refs.tplRefs.last;
               fixture.detectChanges();
               expect(fixture.nativeElement).toHaveText('bar');

               async.done();
             });
       }));
开发者ID:AwelEshetu,项目名称:angular,代码行数:20,代码来源:ng_template_outlet_spec.ts


示例3: inject

       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
         var template = '<div>' +
                        '<ul [ngPlural]="switchValue">' +
                        '<template ngPluralCase="=0"><li>you have no messages.</li></template>' +
                        '<template ngPluralCase="=1"><li>you have one message.</li></template>' +
                        '</ul></div>';

         tcb.overrideTemplate(TestComponent, template)
             .createAsync(TestComponent)
             .then((fixture) => {
               fixture.debugElement.componentInstance.switchValue = 0;
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('you have no messages.');

               fixture.debugElement.componentInstance.switchValue = 1;
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('you have one message.');

               async.done();
             });
       }));
开发者ID:1186792881,项目名称:angular,代码行数:21,代码来源:ng_plural_spec.ts


示例4: inject

       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
         var html =
             '<div><template [ngIf]="booleanCondition"><copy-me *ngIf="nestedBooleanCondition">hello</copy-me></template></div>';

         tcb.overrideTemplate(TestComponent, html)
             .createAsync(TestComponent)
             .then((fixture) => {
               fixture.debugElement.componentInstance.booleanCondition = false;
               fixture.detectChanges();
               expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
                   .toEqual(0);
               expect(fixture.debugElement.nativeElement).toHaveText('');

               fixture.debugElement.componentInstance.booleanCondition = true;
               fixture.detectChanges();
               expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
                   .toEqual(1);
               expect(fixture.debugElement.nativeElement).toHaveText('hello');

               fixture.debugElement.componentInstance.nestedBooleanCondition = false;
               fixture.detectChanges();
               expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
                   .toEqual(0);
               expect(fixture.debugElement.nativeElement).toHaveText('');

               fixture.debugElement.componentInstance.nestedBooleanCondition = true;
               fixture.detectChanges();
               expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
                   .toEqual(1);
               expect(fixture.debugElement.nativeElement).toHaveText('hello');

               fixture.debugElement.componentInstance.booleanCondition = false;
               fixture.detectChanges();
               expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
                   .toEqual(0);
               expect(fixture.debugElement.nativeElement).toHaveText('');

               async.done();
             });
       }));
开发者ID:1186792881,项目名称:angular,代码行数:40,代码来源:ng_if_spec.ts


示例5: inject

         inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div>' +
               '<ul [ngSwitch]="switchValue">' +
               '<template [ngSwitchWhen]="when1"><li>when 1;</li></template>' +
               '<template [ngSwitchWhen]="when2"><li>when 2;</li></template>' +
               '<template ngSwitchDefault><li>when default;</li></template>' +
               '</ul></div>';

           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
                 fixture.debugElement.componentInstance.when1 = 'a';
                 fixture.debugElement.componentInstance.when2 = 'b';
                 fixture.debugElement.componentInstance.switchValue = 'a';
                 fixture.detectChanges();
                 expect(fixture.debugElement.nativeElement).toHaveText('when 1;');

                 fixture.debugElement.componentInstance.switchValue = 'b';
                 fixture.detectChanges();
                 expect(fixture.debugElement.nativeElement).toHaveText('when 2;');

                 fixture.debugElement.componentInstance.switchValue = 'c';
                 fixture.detectChanges();
                 expect(fixture.debugElement.nativeElement).toHaveText('when default;');

                 fixture.debugElement.componentInstance.when1 = 'c';
                 fixture.detectChanges();
                 expect(fixture.debugElement.nativeElement).toHaveText('when 1;');

                 fixture.debugElement.componentInstance.when1 = 'd';
                 fixture.detectChanges();
                 expect(fixture.debugElement.nativeElement).toHaveText('when default;');

                 async.done();
               });
         }));
开发者ID:LordBinary,项目名称:angular,代码行数:36,代码来源:ng_switch_spec.ts


示例6: inject

         inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div>' +
                          '<ul [ng-switch]="switchValue">' +
                          '<template ng-switch-when="a"><li>when a</li></template>' +
                          '<template ng-switch-when="b"><li>when b</li></template>' +
                          '</ul></div>';

           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((rootTC) => {
                 rootTC.detectChanges();
                 expect(rootTC.debugElement.nativeElement).toHaveText('');

                 rootTC.debugElement.componentInstance.switchValue = 'a';
                 rootTC.detectChanges();
                 expect(rootTC.debugElement.nativeElement).toHaveText('when a');

                 rootTC.debugElement.componentInstance.switchValue = 'b';
                 rootTC.detectChanges();
                 expect(rootTC.debugElement.nativeElement).toHaveText('when b');

                 async.done();
               });
         }));
开发者ID:hankduan,项目名称:angular,代码行数:24,代码来源:ng_switch_spec.ts


示例7: compileRoot

function compileRoot(tcb: TestComponentBuilder): Promise<ComponentFixture<any>> {
  return tcb.createAsync(RootCmp);
}
开发者ID:davewragg,项目名称:angular,代码行数:3,代码来源:integration_spec.ts


示例8: inject

         inject([AsyncTestCompleter], (async) => {
           tcb.createAsync(AppWithOutletListeners)
               .then(fixture => {
                 let appInstance = fixture.debugElement.componentInstance;
                 let router = appInstance.router;

                 router.subscribe((_) => {
                   fixture.detectChanges();

                   expect(appInstance.helloCmp).toBeAnInstanceOf(HelloCmp);
                   expect(appInstance.helloCmp.message).toBe('Ahoy');

                   async.done();
                 });

                 // TODO(juliemr): This isn't necessary for the test to pass - figure
                 // out what's going on.
                 // router.navigateByUrl('/rainbow(pony)');
               });
         }));
开发者ID:ChinnasamyM,项目名称:angular,代码行数:20,代码来源:bootstrap_spec.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript upgrade.UpgradeAdapter类代码示例发布时间:2022-05-25
下一篇:
TypeScript testing_internal.Log类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap