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

import { ProjectPictureFormComponent } from './project-picture-form.component';
import { provideRouter } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { AuthService } from '@app/core/services/authentication/auth.service';
import { PROJECT_REPOSITORY_TOKEN } from '@app/infrastructure/projects/project-repository.token';
import { of } from 'rxjs';
import { Project } from '@app/domain/projects/project.model';
import { ProjectRepository } from '@app/domain/projects/project.repository';

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

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

  beforeEach(async () => {
    mockToastrService = {
      success: jest.fn(),
      error: jest.fn(),
      warning: jest.fn(),
    };
    mockAuthService = {
      updateUser: 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)),
    };

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

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

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