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

import { MyProfileUpdateCvFormComponent } from './my-profile-update-cv-form.component';
import { ToastrService } from 'ngx-toastr';
import { AuthService } from '@app/core/services/authentication/auth.service';
import { signal } from '@angular/core';
import { Auth } from '@app/shared/models/auth';
import { provideRouter } from '@angular/router';
import { ProfileRepository } from '@app/domain/profiles/profile.repository';
import { of } from 'rxjs';
import { Profile } from '@app/domain/profiles/profile.model';
import { PROFILE_REPOSITORY_TOKEN } from '@app/infrastructure/profiles/profile-repository.token';

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

  let mockToastrService: Partial<ToastrService>;
  let mockAuthService: Partial<AuthService>;
  let mockProfileRepo: ProfileRepository;

  beforeEach(async () => {
    mockToastrService = {
      success: jest.fn(),
      error: jest.fn(),
      warning: jest.fn(),
    };

    mockProfileRepo = {
      create: jest.fn(),
      list: jest.fn(),
      update: jest.fn().mockReturnValue(of({} as Profile)),
      getByUserId: jest.fn().mockReturnValue(of({} as Profile)),
    };

    mockAuthService = {
      updateUser: jest.fn(),
      user: signal<Auth | undefined>(undefined),
    };

    await TestBed.configureTestingModule({
      imports: [MyProfileUpdateCvFormComponent],
      providers: [
        provideRouter([]),
        { provide: PROFILE_REPOSITORY_TOKEN, useValue: mockProfileRepo },
        { provide: ToastrService, useValue: mockToastrService },
        { provide: AuthService, useValue: mockAuthService },
      ],
    }).compileComponents();

    fixture = TestBed.createComponent(MyProfileUpdateCvFormComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();

    await fixture.whenStable();
  });

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