import { describe, expect, it } from "vitest";
import { seoFields } from "./seo-fields";

describe("seoFields", () => {
  it("is a group field named 'seo'", () => {
    if (seoFields.type !== "group" || !("name" in seoFields)) {
      throw new Error("seoFields must be a named group");
    }
    expect(seoFields.name).toBe("seo");
    expect(seoFields.type).toBe("group");
  });

  it("contains required title and optional description", () => {
    if (seoFields.type !== "group") {
      throw new Error("seoFields must be a group");
    }
    const fieldNames = seoFields.fields.map((f) =>
      "name" in f ? f.name : null,
    );
    expect(fieldNames).toContain("title");
    expect(fieldNames).toContain("description");

    const titleField = seoFields.fields.find(
      (f) => "name" in f && f.name === "title",
    );
    expect(titleField && "required" in titleField && titleField.required).toBe(
      true,
    );
  });
});
