本文整理汇总了TypeScript中@angular/core/testing.TestBed.overrideTemplate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestBed.overrideTemplate方法的具体用法?TypeScript TestBed.overrideTemplate怎么用?TypeScript TestBed.overrideTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/core/testing.TestBed
的用法示例。
在下文中一共展示了TestBed.overrideTemplate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should translate templates', () => {
const tb: ComponentFixture<I18nComponent> =
TestBed.overrideTemplate(I18nComponent, HTML).createComponent(I18nComponent);
const cmp: I18nComponent = tb.componentInstance;
const el: DebugElement = tb.debugElement;
validateHtml(tb, cmp, el);
});
示例2: it
it('should match directives on ng-template created by * syntax', () => {
TestBed.configureTestingModule({declarations: [TestComponent, TestDirective]});
TestBed.overrideTemplate(TestComponent, `<div *test></div>`);
const fixture = TestBed.createComponent(TestComponent);
const nodesWithDirective = fixture.debugElement.queryAllNodes(By.directive(TestDirective));
expect(nodesWithDirective.length).toBe(1);
});
示例3: getFieldComponent
function getFieldComponent(template: string): FieldComponent {
TestBed.overrideTemplate(TestComponent, template);
TestBed.compileComponents();
const fixture = TestBed.createComponent(TestComponent);
fixture.detectChanges();
return fixture.componentInstance.field;
}
示例4: beforeEach
beforeEach(() => {
jasmine.clock().mockDate(DateTime.fromISO('2017-12-29T12:13:00Z').toJSDate());
TestBed.overrideTemplate(ChartComponent, '');
TestBed.configureTestingModule({
declarations: [SpentTimeStatisticsComponent, ChartComponent, DurationPipe, PageTitleDirective],
imports: [RouterTestingModule.withRoutes([
{
path: 'tasks/statistics', component: SpentTimeStatisticsComponent
}
]), ReactiveFormsModule, GlobeNgbModule.forRoot(), CurrentUserModule.forRoot(), HttpClientModule],
providers: [{ provide: ActivatedRoute, useFactory: () => route }]
});
const taskService = TestBed.get(TaskService);
spyOn(taskService, 'spentTimeStatistics').and.returnValue(EMPTY);
});
示例5: executeTest
function executeTest(template: string) {
TestBed.overrideTemplate(DestroyCasesComp, template).configureTestingModule({
schemas: [NO_ERRORS_SCHEMA]
});
const fixture = TestBed.createComponent(DestroyCasesComp);
fixture.detectChanges();
const initial = fixture.nativeElement.innerHTML;
const structDirs = fixture.componentInstance.structDirs.toArray();
structDirs.forEach(structDir => structDir.create());
fixture.detectChanges();
expect(fixture.nativeElement).toHaveText('Foo');
structDirs.forEach(structDir => structDir.destroy());
fixture.detectChanges();
expect(fixture.nativeElement.innerHTML).toEqual(initial);
}
示例6: createHostComponent
function createHostComponent(template: string): ComponentFixture<HostComponent> {
TestBed.overrideTemplate(HostComponent, template);
const fixture = TestBed.createComponent(HostComponent);
fixture.detectChanges();
return fixture as ComponentFixture<HostComponent>;
}
示例7: beforeEach
beforeEach(async(() => {
jasmine.clock().mockDate(DateTime.fromISO('2017-08-01T12:30:00').toJSDate());
const tasks: Array<TaskModel> = [];
for (let i = 0; i < 3; i++) {
tasks.push(
{
id: i,
description: 'Some description',
title: 'Some title',
category: {
id: 6,
name: 'Various'
},
dueDate: '2017-08-01',
status: 'DONE',
totalSpentTimeInMinutes: 0,
assignee: null,
creator: {
id: 1,
login: 'admin'
} as UserModel,
concernedPerson: null
}
);
}
page = {
content: tasks,
number: 0,
size: 3,
totalElements: 8,
totalPages: 3,
};
data = {
taskListType: 'todo',
tasks: page
};
activatedRoute = {
data: of(data),
parent: {
parent: {
snapshot: {
data: {}
}
}
}
} as any;
TestBed.overrideTemplate(SpentTimeAddComponent, '');
TestBed.overrideTemplate(SpentTimesComponent, '');
TestBed.configureTestingModule({
imports: [CurrentUserModule.forRoot(), RouterTestingModule, GlobeNgbModule.forRoot(), HttpClientModule],
declarations: [
TasksPageComponent,
TasksComponent,
FullnamePipe,
SpentTimesComponent,
SpentTimeAddComponent,
DurationPipe,
PageTitleDirective
],
providers: [{ provide: ActivatedRoute, useFactory: () => activatedRoute }]
});
}));