import { async, ComponentFixture, TestBed } from "@angular/core/testing";

import { PerformancesComponent } from "./performances.component";
import { By } from "@angular/platform-browser";
import { RouterLinkWithHref } from "@angular/router";
import { RouterTestingModule } from "@angular/router/testing";

describe("PerformancesComponent", () => {
  let component: PerformancesComponent;
  let fixture: ComponentFixture<PerformancesComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [PerformancesComponent],
      imports: [RouterTestingModule]
    }).compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(PerformancesComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });

  it("Debe de tener un link a la página root", () => {
    const elementos = fixture.debugElement.queryAll(
      By.directive(RouterLinkWithHref)
    );

    // console.log( elementos );

    let existe = false;

    for (const elem of elementos) {
      if (elem.attributes["ng-reflect-router-link"] === "/") {
        existe = true;
        break;
      }
    }

    expect(existe).toBeTruthy();
  });
});
