當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript TestBed.overrideTemplate方法代碼示例

本文整理匯總了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);
    });
開發者ID:lucduong,項目名稱:angular,代碼行數:8,代碼來源:integration_xliff2_spec.ts

示例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);
    });
開發者ID:alxhub,項目名稱:angular,代碼行數:9,代碼來源:directive_spec.ts

示例3: getFieldComponent

function getFieldComponent(template: string): FieldComponent {

  TestBed.overrideTemplate(TestComponent, template);
  TestBed.compileComponents();
  const fixture = TestBed.createComponent(TestComponent);
  fixture.detectChanges();

  return fixture.componentInstance.field;

}
開發者ID:makinacorpus,項目名稱:angular2-schema-form,代碼行數:10,代碼來源:field.component.spec.ts

示例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);
  });
開發者ID:Ninja-Squad,項目名稱:globe42,代碼行數:17,代碼來源:spent-time-statistics.component.spec.ts

示例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);
    }
開發者ID:StephenFluin,項目名稱:angular,代碼行數:19,代碼來源:view_container_ref_spec.ts

示例6: createHostComponent

function createHostComponent(template: string): ComponentFixture<HostComponent> {
  TestBed.overrideTemplate(HostComponent, template);
  const fixture = TestBed.createComponent(HostComponent);
  fixture.detectChanges();
  return fixture as ComponentFixture<HostComponent>;
}
開發者ID:dimpu,項目名稱:angular2-markdown,代碼行數:6,代碼來源:ngx-md.component.spec.ts

示例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 }]
    });
  }));
開發者ID:Ninja-Squad,項目名稱:globe42,代碼行數:68,代碼來源:tasks-page.component.spec.ts


注:本文中的@angular/core/testing.TestBed.overrideTemplate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。