import { describe, it, expect } from "vitest";
import { ZodError } from "zod";
import { getSiteSettingsUseCase } from "@/application/use-cases/get-site-settings.use-case";
import { MockSiteSettingsRepository } from "@/infrastructure/repositories/site-settings.repository.mock";

describe("getSiteSettingsUseCase", () => {
  it("returns the seeded site settings", async () => {
    const repo = new MockSiteSettingsRepository();
    const useCase = getSiteSettingsUseCase(repo);
    const result = await useCase({});
    expect(result.siteName).toBe("My App");
  });

  it("(R25) throws ZodError when repository returns malformed site settings", async () => {
    const malformedRepo = {
      getSiteSettings: async () => ({ siteName: "" }),
    };
    const useCase = getSiteSettingsUseCase(malformedRepo);
    await expect(useCase({})).rejects.toBeInstanceOf(ZodError);
  });
});
