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