本文整理匯總了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 }]
});
}));