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

import { MyProfileUpdateProjectFormComponent } from './my-profile-update-project-form.component';
import { AuthService } from '@app/core/services/authentication/auth.service';
import { ToastrService } from 'ngx-toastr';
import { provideRouter } from '@angular/router';
import { signal } from '@angular/core';
import { Auth } from '@app/shared/models/auth';
import { PROJECT_REPOSITORY_TOKEN } from '@app/infrastructure/projects/project-repository.token';
import { ProjectRepository } from '@app/domain/projects/project.repository';
import { of } from 'rxjs';
import { Project } from '@app/domain/projects/project.model';

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

  let mockAuthService: Partial<AuthService>;
  let mockToastrService: Partial<ToastrService>;
  let mockProjectRepository: jest.Mocked<ProjectRepository>;

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

    mockProjectRepository = {
      create: jest.fn().mockReturnValue(of({} as Project)),
      list: jest.fn().mockReturnValue(of([])),
      get: jest.fn().mockReturnValue(of({} as Project)),
      update: jest.fn().mockReturnValue(of({} as Project)),
    };

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

    await TestBed.configureTestingModule({
      imports: [MyProfileUpdateProjectFormComponent],
      providers: [
        provideRouter([]),
        { provide: AuthService, useValue: mockAuthService },
        { provide: ToastrService, useValue: mockToastrService },
        { provide: PROJECT_REPOSITORY_TOKEN, useValue: mockProjectRepository },
      ],
    }).compileComponents();

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

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