import { describe, expect, it } from "vitest";
import { get{{pascalCase entity}}Controller } from "@/interface-adapters/controllers/get-{{kebabCase entity}}.controller";
import { get{{pascalCase entity}}UseCase } from "@/application/use-cases/get-{{kebabCase entity}}.use-case";
import { Mock{{pascalCase entity}}Repository } from "@/infrastructure/repositories/{{kebabCase entity}}.repository.mock";
import { InputParseError } from "@/entities/errors/common";

describe("get{{pascalCase entity}}Controller", () => {
  it("returns the {{camelCase entity}} for a valid id", async () => {
    const repo = new Mock{{pascalCase entity}}Repository();
    const useCase = get{{pascalCase entity}}UseCase(repo);
    const controller = get{{pascalCase entity}}Controller(useCase);

    const result = await controller({ id: "seed-1" });

    expect(result.id).toBe("seed-1");
  });

  it("throws InputParseError when input is missing fields", async () => {
    const repo = new Mock{{pascalCase entity}}Repository();
    const useCase = get{{pascalCase entity}}UseCase(repo);
    const controller = get{{pascalCase entity}}Controller(useCase);

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

  it("throws InputParseError when input has unexpected fields (strict)", async () => {
    const repo = new Mock{{pascalCase entity}}Repository();
    const useCase = get{{pascalCase entity}}UseCase(repo);
    const controller = get{{pascalCase entity}}Controller(useCase);

    await expect(
      controller({ id: "seed-1", unexpected: true }),
    ).rejects.toBeInstanceOf(InputParseError);
  });
});
