performances.component.spec.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { async, ComponentFixture, TestBed } from "@angular/core/testing";
  2. import { PerformancesComponent } from "./performances.component";
  3. import { By } from "@angular/platform-browser";
  4. import { RouterLinkWithHref } from "@angular/router";
  5. import { RouterTestingModule } from "@angular/router/testing";
  6. describe("PerformancesComponent", () => {
  7. let component: PerformancesComponent;
  8. let fixture: ComponentFixture<PerformancesComponent>;
  9. beforeEach(async(() => {
  10. TestBed.configureTestingModule({
  11. declarations: [PerformancesComponent],
  12. imports: [RouterTestingModule]
  13. }).compileComponents();
  14. }));
  15. beforeEach(() => {
  16. fixture = TestBed.createComponent(PerformancesComponent);
  17. component = fixture.componentInstance;
  18. fixture.detectChanges();
  19. });
  20. it("should create", () => {
  21. expect(component).toBeTruthy();
  22. });
  23. it("Debe de tener un link a la página root", () => {
  24. const elementos = fixture.debugElement.queryAll(
  25. By.directive(RouterLinkWithHref)
  26. );
  27. // console.log( elementos );
  28. let existe = false;
  29. for (const elem of elementos) {
  30. if (elem.attributes["ng-reflect-router-link"] === "/") {
  31. existe = true;
  32. break;
  33. }
  34. }
  35. expect(existe).toBeTruthy();
  36. });
  37. });