import { DigiNgSkeletonBaseModule } from '@af/digi-ng/_skeleton/skeleton-base';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { SortOrder } from '@msfa-enums/sort-order.enum';
import { EmployeeCompactResponse } from '@msfa-models/api/employee.response.model';
import { LayoutComponent } from '@msfa-shared/components/layout/layout.component';
import { EmployeesListComponent } from './employees-list.component';
import { employeesMock } from './employees-list.mock';

describe('EmployeesListComponent', () => {
  let component: EmployeesListComponent;
  let fixture: ComponentFixture<EmployeesListComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      schemas: [CUSTOM_ELEMENTS_SCHEMA],
      declarations: [EmployeesListComponent, LayoutComponent],
      imports: [RouterTestingModule, DigiNgSkeletonBaseModule, HttpClientTestingModule],
    }).compileComponents();

    fixture = TestBed.createComponent(EmployeesListComponent);
    component = fixture.componentInstance;
  });

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

  describe('20 employees sorted by Full name Ascending', () => {
    beforeEach(() => {
      component.employees = employeesMock;
      component.paginationMeta = { count: employeesMock.length, limit: 50, page: 1, totalPage: 3 };
      component.sort = { key: <keyof EmployeeCompactResponse>'fullName', order: SortOrder.ASC };

      fixture.detectChanges();
    });
    //Tester måste fixas efter att man bytt datatyp från Employee till EmployeeCompact, fixa lämplig data i employeeMock osv.

    /* it('should display the rows from employees object 20 rows regardless of pagination', () => {
      expect(getEmployeeRows().length).toBe(20);
    });

    it('should display the up caret next to Full name to indicate that it´s sorted by full name Ascending', () => {
      const fullNameUpCaret = fixture.debugElement.query(By.css('#sort-button-fullName > digi-icon-caret-up'));
      expect(fullNameUpCaret).toBeTruthy();
    });

    it('should only display one caret', () => {
      const upCarets = fixture.debugElement.queryAll(By.css('digi-icon-caret-up'));
      const downCarets = fixture.debugElement.queryAll(By.css('digi-icon-caret-down'));
      expect(upCarets.length + downCarets.length).toBe(1);
    }); */
  });
});
