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


TypeScript testing.TestComponentBuilder類代碼示例

本文整理匯總了TypeScript中@angular/compiler/testing.TestComponentBuilder的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestComponentBuilder類的具體用法?TypeScript TestComponentBuilder怎麽用?TypeScript TestComponentBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TestComponentBuilder類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

describe('Component: Button', () => {
  let builder: TestComponentBuilder;

  beforeEachProviders(() => [SoundBlip]);
  beforeEach(inject([TestComponentBuilder],
    function(tcb: TestComponentBuilder) {
      builder = tcb;
    })
  );

  it('should invoke onClick when clicked',
    async(inject([], () => {
      return builder.createAsync(SoundBlip)
        .then((fixture: ComponentFixture<any>) => {
          spyOn(fixture.componentInstance, 'onClick');
          fixture.componentInstance.qaid = 'button-1';
          fixture.detectChanges();
          let compiled = fixture.debugElement.nativeElement;
          compiled.querySelector('#button-1').click();
          expect(fixture.componentInstance.handleClick).toHaveBeenCalled();
        });
    }))
  );
});
開發者ID:stevenkampen,項目名稱:ng2-sequencer,代碼行數:24,代碼來源:index.test.ts

示例2: expect

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

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

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

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

                     async.done();
                   });
             }));
開發者ID:4vanger,項目名稱:angular,代碼行數:24,代碼來源:ng_switch_spec.ts

示例3: describe

describe('Component: Home', () => {
  let builder: TestComponentBuilder;

  beforeEachProviders(() => [
    HomeComponent,
    TD_LAYOUT_PROVIDERS,
  ]);
  beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder): void {
    builder = tcb;
  }));

  it('should inject the component', inject([HomeComponent], (component: HomeComponent) => {
    expect(component).toBeTruthy();
  }));

  it('should create the component', inject([], () => {
    return builder.createAsync(HomeTestControllerComponent)
      .then((fixture: ComponentFixture<any>) => {
        let query: DebugElement = fixture.debugElement.query(By.directive(HomeComponent));
        expect(query).toBeTruthy();
        expect(query.componentInstance).toBeTruthy();
      });
  }));
});
開發者ID:gitter-badger,項目名稱:covalent,代碼行數:24,代碼來源:home.component.spec.ts

示例4: inject

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

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

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

                 async.done();
               });
         }));
開發者ID:aftab10662,項目名稱:angular,代碼行數:24,代碼來源:ng_if_spec.ts

示例5: inject

       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
         var template = `<div [ngStyle]="expr"></div>`;

         tcb.overrideTemplate(TestComponent, template)
             .createAsync(TestComponent)
             .then((fixture) => {
               var expr: Map<string, any>;

               fixture.debugElement.componentInstance.expr = {'max-width': '40px'};
               fixture.detectChanges();
               expect(
                   getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
                   .toEqual('40px');

               expr = fixture.debugElement.componentInstance.expr;
               (expr as any /** TODO #9100 */)['max-width'] = '30%';
               fixture.detectChanges();
               expect(
                   getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
                   .toEqual('30%');

               async.done();
             });
       }));
開發者ID:aftab10662,項目名稱:angular,代碼行數:24,代碼來源:ng_style_spec.ts

示例6: advance

		(tcb: TestComponentBuilder, location: Location, angulartics2: Angulartics2, angulartics2Piwik: Angulartics2Piwik) => {
		  fixture = tcb.createFakeAsync(RootCmp);
		  angulartics2.setUserProperties.next({ userId: '1', firstName: 'John', lastName: 'Doe' });
		  advance(fixture);
		  expect(_paq).toContain(['setCustomVariable', { userId: '1', firstName: 'John', lastName: 'Doe' }]);
		})));
開發者ID:IDEXXIHD,項目名稱:angulartics2,代碼行數:6,代碼來源:angulartics2-piwik.spec.ts

示例7:

const compile = (tcb: TestComponentBuilder, template: string = '') => {
  return tcb
    .overrideTemplate(TestComponent, template)
    .createAsync(TestComponent);
};
開發者ID:CoderMonkies,項目名稱:router,代碼行數:5,代碼來源:link-to.spec.ts


注:本文中的@angular/compiler/testing.TestComponentBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。