import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { MatDialogModule } from '@angular/material/dialog';
import { MatTableModule } from '@angular/material/table';
import { ToastrModule } from 'ngx-toastr';
import { DatePipe } from '@angular/common';
import { PxeComponent } from './pxe.component';
import { DataService } from './data.service';
import { MatAccordion } from '@angular/material/expansion';
import { MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle, MatExpansionPanelDescription } from '@angular/material/expansion';
import { MatIcon } from '@angular/material/icon';
import { MatDivider } from '@angular/material/divider';
import { MatFormField } from '@angular/material/form-field';
import { MatLabel } from '@angular/material/form-field';
import { MatHint } from '@angular/material/form-field';
import { MatSelect } from '@angular/material/select';
import { MatOption } from '@angular/material/select';
import { MatPaginator } from '@angular/material/paginator';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { TranslateModule } from '@ngx-translate/core';
import { JoyrideModule } from 'ngx-joyride';
import { LoadingComponent } from '../../../shared/loading/loading.component';
import { ConfigService } from '@services/config.service';

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

  beforeEach(async () => {
    const mockConfigService = {
      apiUrl: 'http://mock-api-url',
      mercureUrl: 'http://mock-mercure-url'
    };

    await TestBed.configureTestingModule({
      declarations: [PxeComponent, LoadingComponent],
      imports: [
        FormsModule,
        MatInputModule,
        MatSelectModule,
        BrowserAnimationsModule,
        MatDialogModule,
        MatTableModule,
        MatAccordion, MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle,  
        MatExpansionPanelDescription,
        MatIcon,
        MatDivider,
        MatFormField,
        MatLabel,
        MatHint,
        MatSelect,
        MatOption,
        MatPaginator,
        ToastrModule.forRoot(),
        TranslateModule.forRoot(),
        JoyrideModule.forRoot(),
      ],
      providers: [
        DatePipe,
        DataService,
        { provide: ConfigService, useValue: mockConfigService },
        provideHttpClient(),           
        provideHttpClientTesting()       
      ]
    }).compileComponents();
  });

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

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

  it('should have a defined component', () => {
    expect(component).toBeDefined();
  });

  it('should have a defined baseUrl', () => {
    expect(component.baseUrl).toBeDefined();
  });

  it('should have a defined pxeTemplates', () => {
    expect(component.pxeTemplates).toBeDefined();
  });

  it('should have a defined currentPage', () => {
    expect(component.currentPage).toBeDefined();
  });

  it('should have a defined dataSource', () => {
    expect(component.dataSource).toBeDefined();
  });

  it('should have a defined length', () => {
    expect(component.length).toBeDefined();
  });

  it('should have a defined itemsPerPage', () => {
    expect(component.itemsPerPage).toBeDefined();
  });

  it('should have a defined page', () => {
    expect(component.page).toBeDefined();
  });

  it('should have a defined pageSizeOptions', () => {
    expect(component.pageSizeOptions).toBeDefined();
  });

  it('should have a defined selectedElements', () => {
    expect(component.selectedElements).toBeDefined();
  });

  it('should have a defined loading', () => {
    expect(component.loading).toBeDefined();
  });

  it('should have a defined filters', () => {
    expect(component.filters).toBeDefined();
  });

  it('should have a defined alertMessage', () => {
    expect(component.alertMessage).toBeDefined();
  });

  it('should have a defined datePipe', () => {
    expect(component.datePipe).toBeDefined();
  });

  it('should have a defined selectedItem', () => {
    expect(component.selectedItem).toBeDefined();
  });
});