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


TypeScript TestComponentBuilder.overrideTemplate方法代码示例

本文整理汇总了TypeScript中angular2/testing.TestComponentBuilder.overrideTemplate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestComponentBuilder.overrideTemplate方法的具体用法?TypeScript TestComponentBuilder.overrideTemplate怎么用?TypeScript TestComponentBuilder.overrideTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/testing.TestComponentBuilder的用法示例。


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

示例1: it

    it('can select by value', (done: () => void) => {
      builder
        .overrideTemplate(TestApp, `
            <md-radio-group>
              <md-radio-button value="1"></md-radio-button>
              <md-radio-button value="2"></md-radio-button>
            </md-radio-group>`)
        .createAsync(TestApp)
        .then((fixture) => {
          let buttons = fixture.debugElement.queryAll(By.css('md-radio-button'));
          let group = fixture.debugElement.query(By.css('md-radio-group'));

          fixture.detectChanges();
          expect(group.componentInstance.selected).toBe(null);

          group.componentInstance.value = '2';

          fixture.detectChanges();
          expect(group.componentInstance.selected).toBe(buttons[1].componentInstance);
        }).then(done);
    });
开发者ID:LuanNg,项目名称:material2,代码行数:21,代码来源:radio.spec.ts

示例2: it

    it('should be focusable', (done: () => void) => {
      builder
        .overrideTemplate(TestApp, '<md-radio-button></md-radio-button>')
        .createAsync(TestApp)
        .then((fixture) => {
          let button = fixture.debugElement.query(By.css('md-radio-button'));
          let input = button.query(By.css('input'));

          fixture.detectChanges();
          expect(button.nativeElement.classList.contains('md-radio-focused')).toBe(false);

          let event = createEvent('focus');
          input.nativeElement.dispatchEvent(event);
          fixture.detectChanges();
          expect(button.nativeElement.classList.contains('md-radio-focused')).toBe(true);

          event = createEvent('blur');
          input.nativeElement.dispatchEvent(event);
          fixture.detectChanges();
          expect(button.nativeElement.classList.contains('md-radio-focused')).toBe(false);
        }).then(done);
    });
开发者ID:tkhemani,项目名称:a2MaterialAlpha,代码行数:22,代码来源:radio_button.spec.ts

示例3: it

  it('should send commands during a tap', injectAsync([TestComponentBuilder, ReactNativeRootRenderer], (tcb: TestComponentBuilder, _rootRenderer: ReactNativeRootRenderer) => {
    var rootRenderer = _rootRenderer;
    return tcb.overrideTemplate(TestComponent, `<View rippleFeedback></View>`)
      .createAsync(TestComponent).then((fixture: ComponentFixture) => {
        fixture.detectChanges();
        rootRenderer.executeCommands();
        mock.clearLogs();

        var target = fixture.elementRef.nativeElement.children[0].children[0];
        fireEvent('topTouchStart', target, 0, [[50, 0]]);
        fixture.detectChanges();
        rootRenderer.executeCommands();
        expect(mock.commandLogs.toString()).toEqual(
          'COMMAND+3+hotspotUpdate+50,0,COMMAND+3+setPressed+true');
        mock.clearLogs();

        fireEvent('topTouchEnd', target, 40, [[100, 0]]);
        fixture.detectChanges();
        rootRenderer.executeCommands();
        expect(mock.commandLogs.toString()).toEqual(
          'COMMAND+3+hotspotUpdate+100,0,COMMAND+3+setPressed+false');
      });
  }));
开发者ID:DrMabuse23,项目名称:react-native-renderer,代码行数:23,代码来源:ripple_feedback_spec.ts

示例4: it

  it('should change opacity during a tap', injectAsync([TestComponentBuilder, ReactNativeRootRenderer], (tcb: TestComponentBuilder, _rootRenderer: ReactNativeRootRenderer) => {
    var rootRenderer = _rootRenderer;
    return tcb.overrideTemplate(TestComponent, `<View opacityFeedback></View>`)
      .createAsync(TestComponent).then((fixture: ComponentFixture) => {
        fixture.detectChanges();
        rootRenderer.executeCommands();
        mock.clearLogs();

        var target = fixture.elementRef.nativeElement.children[0].children[0];
        fireEvent('topTouchStart', target, 0, [[0, 0]]);
        fixture.detectChanges();
        rootRenderer.executeCommands();
        expect(mock.commandLogs.toString()).toEqual(
          'UPDATE+3+native-view+{"opacity":0.5}');
        mock.clearLogs();

        fireEvent('topTouchEnd', target, 40, [[100, 0]]);
        fixture.detectChanges();
        rootRenderer.executeCommands();
        expect(mock.commandLogs.toString()).toEqual(
          'UPDATE+3+native-view+{"opacity":1}');
      });
  }));
开发者ID:DrMabuse23,项目名称:react-native-renderer,代码行数:23,代码来源:opacity_feedback_spec.ts

示例5: Promise

 (tcb: TestComponentBuilder, router: Router, angulartics2: Angulartics2) => {
   return tcb.overrideTemplate(RootCmp, `<div [angulartics2On]="'click'" [angularticsEvent]="'InitiateSearch'" [angularticsCategory]="'Search'"></div>`)
     .createAsync(RootCmp)
     .then((rtc) => fixture = rtc)
     .then((_) => {
       fixture.detectChanges();
       return new Promise((resolve) => {
         expect(EventSpy).not.toHaveBeenCalled();
         angulartics2.eventTrack.subscribe((x: any) => EventSpy(x));
         compiled = fixture.debugElement.nativeElement.children[0];
         compiled.click();
         resolve();
       });
     })
     .then((_) => {
       fixture.detectChanges();
       return new Promise((resolve) => {
         setTimeout(() => {
           expect(EventSpy).toHaveBeenCalledWith({ action: 'InitiateSearch', properties: { category: 'Search', eventType: 'click' } });
           resolve();
         });
       });
     });
 }));
开发者ID:NathanWalker,项目名称:angulartics2,代码行数:24,代码来源:angulartics2On.spec.ts

示例6:

const compile = (tcb: TestComponentBuilder, template: string = '') => {
  return tcb
    .overrideTemplate(TestComponent, template)
    .createAsync(TestComponent);
};
开发者ID:jennyraj,项目名称:router,代码行数:5,代码来源:link-to.spec.ts

示例7: injectAsync

		injectAsync([TestComponentBuilder], (builder :TestComponentBuilder) => {		
			return builder.overrideTemplate(MovieList, "")
					      .createAsync(MovieList).then(fixture => {
				component = fixture.componentInstance;
			})
		})		
开发者ID:HansS,项目名称:AtTheMovies-angular2-scott-allen,代码行数:6,代码来源:MovieListSpecB.ts


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