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


TypeScript TestComponentBuilder.overrideTemplate方法代码示例

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


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

示例1: injectAsync

      injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        return tcb.overrideTemplate(TestComponent, '<div><about></about></div>')
          .createAsync(TestComponent)
          .then((rootTC) => {
            rootTC.detectChanges();

            let aboutInstance = rootTC.debugElement.componentViewChildren[0].componentInstance;
            let aboutDOMEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
            let nameListLen = function () {
              return aboutInstance.list.names.length;
            };

            expect(aboutInstance.list).toEqual(jasmine.any(NameList));
            expect(nameListLen()).toEqual(4);
            expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(nameListLen());

            aboutInstance.addName({value: 'Minko'});
            rootTC.detectChanges();

            expect(nameListLen()).toEqual(5);
            expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(nameListLen());

            expect(DOM.querySelectorAll(aboutDOMEl, 'li')[4].textContent).toEqual('Minko');
          });
      }));
开发者ID:RobertGardner,项目名称:migrations,代码行数:25,代码来源:about_spec.ts

示例2: inject

       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
         var html =
             '<div>' +
             '<copy-me template="ngIf numberCondition + 1 >= 2">helloNumber</copy-me>' +
             '<copy-me template="ngIf stringCondition == \'foo\'">helloString</copy-me>' +
             '<copy-me template="ngIf functionCondition(stringCondition, numberCondition)">helloFunction</copy-me>' +
             '</div>';

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

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

               fixture.debugElement.componentInstance.numberCondition = 1;
               fixture.debugElement.componentInstance.stringCondition = "bar";
               fixture.detectChanges();
               expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
                   .toEqual(1);
               expect(fixture.debugElement.nativeElement).toHaveText('helloNumber');
               async.done();
             });
       }));
开发者ID:1186792881,项目名称:angular,代码行数:32,代码来源:ng_if_spec.ts

示例3: inject

         inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
             	    fixture.detectChanges();
                     //remove item
					fixture.componentInstance.data.removeAt(0);
                      
					setTimeout(() => {					
                        fixture.detectChanges();
						expect($(fixture.debugElement.nativeElement).find("#tree1 li.ui-igtree-noderoot").length)
						.toBe(3);                      
                        //add item
                        fixture.componentInstance.data.push({ Name: "Category", ProductCategoryID: 100});
                        	setTimeout(() => {					
                            fixture.detectChanges();
                            expect($(fixture.debugElement.nativeElement).find("#tree1 li.ui-igtree-noderoot").length)
                            .toBe(4);   
                                expect($(fixture.debugElement.nativeElement).find("#tree1 li.ui-igtree-noderoot").last().children("a").text())
                                .toBe("Category");                         
                            async.done();
                        }, 10);						
					}, 10);
               });
         }));
开发者ID:babually,项目名称:igniteui-angular2,代码行数:26,代码来源:igtree.spec.ts

示例4: inject

         inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div>' +
               '<ul [ngSwitch]="switchValue">' +
               '<template ngSwitchWhen="a"><li>when a1;</li></template>' +
               '<template ngSwitchWhen="b"><li>when b1;</li></template>' +
               '<template ngSwitchWhen="a"><li>when a2;</li></template>' +
               '<template ngSwitchWhen="b"><li>when b2;</li></template>' +
               '<template ngSwitchDefault><li>when default1;</li></template>' +
               '<template ngSwitchDefault><li>when default2;</li></template>' +
               '</ul></div>';

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

                 fixture.debugElement.componentInstance.switchValue = 'a';
                 fixture.detectChanges();
                 expect(fixture.debugElement.nativeElement).toHaveText('when a1;when a2;');

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

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

示例5: inject

 inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
   tcb.overrideTemplate(MyComp, `<div [class.a]="true" #el>Class: {{el.className}}</div>`)
       .createAsync(MyComp)
       .then((fixture) => {
         fixture.detectChanges();
         expect(fixture.nativeElement).toHaveText('Class: a');
         async.done();
       });
 }));
开发者ID:CutiePanther,项目名称:angular,代码行数:9,代码来源:regression_integration_spec.ts

示例6: injectAsync

 injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
   return tcb.overrideTemplate(TestComponent, '<div><app></app></div>')
     .createAsync(TestComponent)
     .then(rootTC => {
       rootTC.detectChanges();
       let appDOMEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
       expect(DOM.querySelectorAll(appDOMEl, 'section > nav > a')[1].href).toMatch(/http:\/\/localhost:\d+\/about/);
     });
 }));
开发者ID:RobertGardner,项目名称:migrations,代码行数:9,代码来源:app_spec.ts

示例7: injectAsync

      injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        return tcb.overrideTemplate(TestComponent, '<div><home></home></div>')
          .createAsync(TestComponent)
          .then((rootTC) => {
            let homeDOMEl = rootTC.debugElement.componentViewChildren[0].nativeElement;

            expect(DOM.querySelectorAll(homeDOMEl, 'h1')[0].textContent).toEqual('Howdy!');
          });
      }));
开发者ID:RobertGardner,项目名称:migrations,代码行数:9,代码来源:home_spec.ts

示例8: it

         it('Zoombar should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
           var template = '<div><ig-data-chart  widgetId="datachart1" [(options)]="opts"></ig-data-chart><ig-zoombar [(options)]="zoombarOpts" widgetId="zoombar"></ig-zoombar></div>';
           tcb.overrideTemplate(TestComponent, template)
               .createAsync(TestComponent)
               .then((fixture) => {
					fixture.detectChanges();
					expect(fixture.debugElement.componentInstance.viewChild2).toBeAnInstanceOf(Infragistics.IgZoombarComponent);
					async.done();
               });
         }));         
开发者ID:babually,项目名称:igniteui-angular2,代码行数:10,代码来源:chart.spec.ts

示例9: inject

 inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
   var template = '<div>{{text}}<span ngNonBindable>{{text}}</span></div>';
   tcb.overrideTemplate(TestComponent, template)
       .createAsync(TestComponent)
       .then((fixture) => {
         fixture.detectChanges();
         expect(fixture.debugElement.nativeElement).toHaveText('foo{{text}}');
         async.done();
       });
 }));
开发者ID:1186792881,项目名称:angular,代码行数:10,代码来源:non_bindable_spec.ts


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