本文整理匯總了TypeScript中@angular/compiler/testing.TestComponentBuilder.overrideTemplate方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestComponentBuilder.overrideTemplate方法的具體用法?TypeScript TestComponentBuilder.overrideTemplate怎麽用?TypeScript TestComponentBuilder.overrideTemplate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/compiler/testing.TestComponentBuilder
的用法示例。
在下文中一共展示了TestComponentBuilder.overrideTemplate方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: expect
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
var template = `<template [ngTemplateOutlet]="null"></template>`;
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((fixture) => {
fixture.detectChanges();
expect(fixture.nativeElement).toHaveText('');
async.done();
});
}));
示例2: inject
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
tcb.overrideTemplate(TestCmp, `
<ul>
<li *ngFor="let item of collection | paginate: config" class="list-item">{{ item }}</li>
</ul>
<pagination-controls autoHide="false"></pagination-controls>`)
.createAsync(TestCmp)
.then((fixture: ComponentFixture<TestCmp>) => {
fixture.detectChanges();
expect(fixture.componentInstance.directionLinks).toBe(false);
});
}));
示例3: it
it('should define default values for value and bufferValue attributes', (done: () => void) => {
builder
.overrideTemplate(TestApp, '<md-progress-bar></md-progress-bar>')
.createAsync(TestApp)
.then((fixture) => {
fixture.detectChanges();
let progressElement = fixture.debugElement.query(By.css('md-progress-bar'));
expect(progressElement.componentInstance.value).toBe(0);
expect(progressElement.componentInstance.bufferValue).toBe(0);
done();
});
});
示例4: it
it('should detect and apply changes to model', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
var template = '<div><ig-grid [(widgetId)]="gridID" [(options)]="opts"></ig-grid></div>';
return tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((fixture) => {
fixture.detectChanges();
$(fixture.debugElement.nativeElement).find("#grid1 tr[data-id='2'] td[aria-describedby='grid1_Name']").click();
$(fixture.debugElement.nativeElement).find("#grid1").igGridUpdating("setCellValue", 2, "Name", "Mary Jackson");
$(fixture.debugElement.nativeElement).find("#grid1_container #grid1_updating_done").click();
expect(fixture.debugElement.componentInstance.data[1].Name)
.toBe("Mary Jackson");
});
}));
示例5: Promise
return new Promise((resolve, reject) => {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((fixture) => {
fixture.detectChanges();
fixture.componentInstance.data = "<span>Test Update</span>";
setTimeout(function () {
fixture.detectChanges();
expect($("#htmlEditor").igHtmlEditor("getContent", "html")).toBe("<span>Test Update</span>");
resolve();
}, 10);
});
});
示例6: it
it('should set the correct list height in fixed mode', async(() => {
var template = `
<md-grid-list cols="1" rowHeight="100px">
<md-grid-tile></md-grid-tile>
<md-grid-tile></md-grid-tile>
</md-grid-list>`;
builder.overrideTemplate(TestGridList, template).createAsync(TestGridList).then(fixture => {
fixture.detectChanges();
let list = fixture.debugElement.query(By.directive(MdGridList));
expect(getProp(list, 'height')).toBe('201px');
});
}));
示例7: it
it('should throw error if tile colspan is wider than total cols', () => {
var template = `
<md-grid-list cols="4">
<md-grid-tile colspan="5"></md-grid-tile>
</md-grid-list>
`;
return builder.overrideTemplate(TestGridList, template)
.createAsync(TestGridList).then((fixture: ComponentFixture<TestGridList>) => {
expect(() => {
fixture.detectChanges();
}).toThrowError(/tile with colspan 5 is wider than grid/);
});
});
示例8: async
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
var template = '<ig-tab-bar></ig-tab-bar>';
return tcb.overrideTemplate(TestComponentDI, template)
.createAsync(TestComponentDI)
.then((fixture) => {
expect(fixture.componentInstance.viewChild).toBeDefined();
expect(fixture.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.TabBar);
//expect(fixture.componentInstance.viewChild.state).toBeAnInstanceOf(Infragistics.NavigationService);
}).catch (reason => {
console.log(reason);
return Promise.reject(reason);
});
})));
示例9: Promise
return new Promise((resolve, reject) => {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((fixture) => {
fixture.detectChanges();
fixture.componentInstance.data[0].Name = "Test";
setTimeout(() => {
fixture.detectChanges();
expect($($("#tree1").igTree("nodeByIndex", 0)).children("a").text())
.toBe("Test");
resolve();
}, 10);
});
});