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


TypeScript test_lib.TestComponentBuilder类代码示例

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


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

示例1: inject

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

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

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

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

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

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

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

示例2: inject

      inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
        tcb.overrideTemplate(TestComponent, '<div><todo></todo></div>')
          .createAsync(TestComponent)
          .then((rootTC) => {
            rootTC.detectChanges();

            let todoInstance = rootTC.debugElement.componentViewChildren[0].componentInstance;
            let aboutDOMEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
            var todosListLen = function () {
              return todoInstance.todoService.get().length;
            };

            expect(todosListLen()).toEqual(2);
            expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(todosListLen());

            todoInstance.add({value: 'Test'});
            rootTC.detectChanges();

            expect(todosListLen()).toEqual(3);
            expect(DOM.querySelectorAll(aboutDOMEl, 'li').length).toEqual(todosListLen());

            expect(DOM.querySelectorAll(aboutDOMEl, 'li')[2].textContent).toContain('Test');

            async.done();
          });
      }));
开发者ID:lakshmiaswath,项目名称:angular2-todo,代码行数:26,代码来源:todo.component.spec.ts

示例3: inject

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

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

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

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

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

示例4: inject

      inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
        tcb.overrideTemplate(TestComponent, '<div><offers></offers></div>')
          .createAsync(TestComponent)
          .then((rootTC) => {
            rootTC.detectChanges();

            var offersComponentInstance = rootTC.componentViewChildren[0].componentInstance;
            var componentDOMEl = rootTC.componentViewChildren[0].nativeElement;
            var listLen = function () {
              return offersComponentInstance.offers.length;
            }

            expect(offersComponentInstance.offers).toEqual(jasmine.any(HotelbookingServiceImpl.getOffers()));
            expect(listLen()).toEqual(2);
            expect(DOM.querySelectorAll(componentDOMEl, 'li').length).toEqual(listLen());

            //offersComponentInstance.addName({value: 'Minko'});
            HotelbookingServiceImpl.addOffer(new Offer('93475', 'Hotel Test', 98.98));
            rootTC.detectChanges();

            expect(listLen()).toEqual(3);
            expect(DOM.querySelectorAll(componentDOMEl, 'li').length).toEqual(listLen());

            expect(DOM.querySelectorAll(componentDOMEl, 'li')[4].textContent).toEqual('Hotel Test');

            async.done();
          });
      }));
开发者ID:Anhmike,项目名称:hotelbooking-angular2,代码行数:28,代码来源:OffersComponent_spec.ts

示例5: inject

 inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
   tcb.createAsync(AppCmp).then((rootTC) => {
     var router = rootTC.componentInstance.router;
     PromiseWrapper.catchError(router.navigate('/cause-error'), (error) => {
       expect(rootTC.nativeElement).toHaveText('outer { oh no }');
       expect(error).toContainError('oops!');
       async.done();
     });
   });
 }));
开发者ID:goderbauer,项目名称:angular,代码行数:10,代码来源:router_integration_spec.ts

示例6: inject

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

示例7: inject

      inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
        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!');

            async.done();
          });
      }));
开发者ID:lakshmiaswath,项目名称:angular2-todo,代码行数:11,代码来源:home.component.spec.ts


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