import { describe, expect, it } from "vitest";
import { ZodError } from "zod";
import { getHeaderUseCase } from "@/application/use-cases/get-header.use-case";
import { MockHeaderRepository } from "@/infrastructure/repositories/header.repository.mock";

describe("getHeaderUseCase", () => {
  it("returns the seeded header items", async () => {
    const repo = new MockHeaderRepository();
    const useCase = getHeaderUseCase(repo);
    const result = await useCase({});
    expect(result.items.length).toBeGreaterThan(0);
    expect(result.items[0]?.label).toBe("Home");
  });

  it("(R25) throws ZodError when repository returns malformed header", async () => {
    const malformedRepo = {
      getHeader: async () =>
        ({ items: [{ label: "", href: "/", external: false }] }) as never,
    };
    const useCase = getHeaderUseCase(malformedRepo);
    await expect(useCase({})).rejects.toBeInstanceOf(ZodError);
  });
});
