当前位置: 首页>>代码示例>>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;未经允许,请勿转载。