import { describe, it, expect } from "vitest";
import { signOutController } from "@/interface-adapters/controllers/sign-out.controller";
import { signOutUseCase } from "@/application/use-cases/sign-out.use-case";
import { MockAuthenticationService } from "@/infrastructure/services/authentication.service.mock";
import { MockUsersRepository } from "@/infrastructure/repositories/users.repository.mock";
import { InputParseError } from "@/entities/errors/common";

describe("signOutController", () => {
  it("returns void on successful sign-out", async () => {
    const users = new MockUsersRepository([]);
    const auth = new MockAuthenticationService(users);
    const useCase = signOutUseCase(auth);
    const controller = signOutController(useCase);

    const result = await controller({ sessionId: "any" });
    expect(result).toBeUndefined();
  });

  it("throws InputParseError on missing sessionId", async () => {
    const users = new MockUsersRepository([]);
    const auth = new MockAuthenticationService(users);
    const useCase = signOutUseCase(auth);
    const controller = signOutController(useCase);

    await expect(controller({} as unknown)).rejects.toBeInstanceOf(InputParseError);
  });
});
