import { describe, it, expect, beforeEach } from "vitest";
import { InMemoryContactsRepository } from "../repositories/in-memory-contacts-repository";
import { GetAllContactsUseCase } from "./get-all-contacts-use-case";

let contactsRepository: InMemoryContactsRepository;
let sut: GetAllContactsUseCase;

describe("Get All Contacts Use Case", () => {
  beforeEach(() => {
    contactsRepository = new InMemoryContactsRepository();
    sut = new GetAllContactsUseCase(contactsRepository);
  });

  it("should be able to get all contacts", async () => {
    await contactsRepository.createMany(["user1@example.com", "user2@example.com"]);

    const { contacts } = await sut.execute();

    expect(contacts).toHaveLength(2);
  });
});
