import { describe, expect, it } from "vitest";
import { galleryItems } from "./gallery";

describe("gallery.ts", () => {
  it("exports an array of gallery items", () => {
    expect(Array.isArray(galleryItems)).toBe(true);
    expect(galleryItems.length).toBeGreaterThan(0);
  });

  it("each item has a url and optional label when present", () => {
    for (const item of galleryItems) {
      expect(typeof item.url).toBe("string");
      expect(item.url.length).toBeGreaterThan(0);
      if (item.label !== undefined) {
        expect(typeof item.label).toBe("string");
        expect(item.label.length).toBeGreaterThan(0);
      }
    }
  });

  it("optional fields are either undefined or correct types", () => {
    for (const item of galleryItems) {
      if (item.alt !== undefined) {
        expect(typeof item.alt).toBe("string");
      }
      if (item.href !== undefined) {
        expect(typeof item.href).toBe("string");
      }
      if (item.span !== undefined) {
        expect(["normal", "wide", "tall"]).toContain(item.span);
      }
    }
  });

  it("contains expected known entries", () => {
    const urls = galleryItems.map((i) => i.url);
    expect(urls).toContain("/images/gallery-honey.jpg");
    expect(urls).toContain("/images/gallery-sourdough.jpg");
  });
});
