| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import { async, ComponentFixture, TestBed } from "@angular/core/testing";
- import { SidebarComponent } from "./sidebar.component";
- import { By } from "@angular/platform-browser";
- import { RouterLinkWithHref } from "@angular/router";
- import { RouterTestingModule } from "@angular/router/testing";
- import { HttpClientModule } from "@angular/common/http";
- import { AuthService } from "../../../services/auth2.service";
- describe("SidebarComponent", () => {
- let component: SidebarComponent;
- let fixture: ComponentFixture<SidebarComponent>;
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- declarations: [SidebarComponent],
- imports: [RouterTestingModule, HttpClientModule],
- providers: [AuthService]
- }).compileComponents();
- }));
- beforeEach(() => {
- fixture = TestBed.createComponent(SidebarComponent);
- 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) {
- console.log(elem.attributes);
- if (elem.attributes["ng-reflect-router-link"] === "/dashboard") {
- existe = true;
- break;
- }
- }
- expect(existe).toBeTruthy();
- });
- });
|