本文整理汇总了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);
});
示例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);
});
示例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');
});
}));
示例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}');
});
}));
示例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();
});
});
});
}));
示例6:
const compile = (tcb: TestComponentBuilder, template: string = '') => {
return tcb
.overrideTemplate(TestComponent, template)
.createAsync(TestComponent);
};
示例7: injectAsync
injectAsync([TestComponentBuilder], (builder :TestComponentBuilder) => {
return builder.overrideTemplate(MovieList, "")
.createAsync(MovieList).then(fixture => {
component = fixture.componentInstance;
})
})