import { FakeProjectRepository } from '@app/testing/domain/projects/fake-project.repository';
import { ListProjectUseCase } from '@app/application/projects/list-project.usecase';
import { mockProjects } from '@app/testing/project.mock';

describe('ListProjectUseCase', () => {
  let useCase: ListProjectUseCase;
  let repo: FakeProjectRepository;

  beforeEach(() => {
    repo = new FakeProjectRepository();
    useCase = new ListProjectUseCase(repo);
  });

  it("doit retourne la liste des projets d'un utilisateur en fonction de l'id", (done) => {
    const userId = 'user_001';
    useCase.execute(userId).subscribe((projects) => {
      expect(projects.length).toBe(mockProjects.filter((p) => p.utilisateur === userId).length);
      expect(projects.every((p) => p.utilisateur === userId)).toBeTruthy();
      done();
    });
  });
});
