當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript testing_internal.TestComponentBuilder類代碼示例

本文整理匯總了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;未經允許,請勿轉載。