import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ShowClientsComponent } from './show-clients.component';
import { MatExpansionModule } from "@angular/material/expansion";
import { MatIconModule } from "@angular/material/icon";
import { MatDividerModule } from "@angular/material/divider";
import { MatFormFieldModule } from "@angular/material/form-field";
import { MatSelectModule } from "@angular/material/select";
import { MatPaginatorModule } from "@angular/material/paginator";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { FormsModule } from "@angular/forms";
import { MatInputModule } from "@angular/material/input";
import { MatTableModule } from "@angular/material/table";
import { TranslateModule } from "@ngx-translate/core";
import { JoyrideModule } from "ngx-joyride";
import { MatDialog, MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog";
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient } from '@angular/common/http';
import { ToastrService } from "ngx-toastr";
import { of } from "rxjs";
import { LoadingComponent } from '../../../shared/loading/loading.component';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { ConfigService } from '@services/config.service';

describe('ShowClientsComponent', () => {
  let component: ShowClientsComponent;
  let fixture: ComponentFixture<ShowClientsComponent>;
  let mockDialog: jasmine.SpyObj<MatDialog>;
  let mockHttpClient: jasmine.SpyObj<HttpClient>;
  let mockToastrService: jasmine.SpyObj<ToastrService>;

  beforeEach(async () => {
    const mockConfigService = {
      apiUrl: 'http://mock-api-url',
      mercureUrl: 'http://mock-mercure-url'
    };
    mockDialog = jasmine.createSpyObj('MatDialog', ['open']);
    mockToastrService = jasmine.createSpyObj('ToastrService', ['success', 'error']);

    await TestBed.configureTestingModule({
      declarations: [ShowClientsComponent, LoadingComponent],
      imports: [
        MatExpansionModule,
        MatIconModule,
        MatDividerModule,
        MatFormFieldModule,
        MatSelectModule,
        MatPaginatorModule,
        BrowserAnimationsModule,
        FormsModule,
        MatInputModule,
        MatDialogModule,
        MatTableModule,
        TranslateModule.forRoot(),
        JoyrideModule.forRoot(),
        HttpClientTestingModule,
        MatProgressSpinnerModule
      ],
      providers: [
        { provide: MatDialog, useValue: mockDialog },
        { provide: ToastrService, useValue: mockToastrService },
        { provide: MatDialogRef, useValue: {} },
        { provide: MAT_DIALOG_DATA, useValue: {} },
        { provide: ConfigService, useValue: mockConfigService }
      ],
    })
    .compileComponents();

    fixture = TestBed.createComponent(ShowClientsComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

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