import { describe, expect, it } from "vitest"; import { pageSchema, pageStatusSchema } from "./page"; describe("pageSchema", () => { it("accepts a minimal valid page", () => { const result = pageSchema.parse({ id: "p1", title: "About", slug: "about", hero: { heading: "About us" }, layout: [], seo: { title: "About — My App" }, createdAt: new Date(), updatedAt: new Date(), }); expect(result.status).toBe("draft"); expect(result.publishedAt).toBeNull(); }); it("accepts a published page with publishedAt", () => { const result = pageSchema.parse({ id: "p1", title: "About", slug: "about", hero: { heading: "About us" }, layout: [], status: "published", publishedAt: new Date(), seo: { title: "About" }, createdAt: new Date(), updatedAt: new Date(), }); expect(result.status).toBe("published"); expect(result.publishedAt).toBeInstanceOf(Date); }); it("rejects empty title", () => { expect(() => pageSchema.parse({ id: "p1", title: "", slug: "about", hero: { heading: "h" }, layout: [], seo: { title: "x" }, createdAt: new Date(), updatedAt: new Date(), }), ).toThrow(); }); }); describe("pageStatusSchema", () => { it("accepts draft and published", () => { expect(pageStatusSchema.parse("draft")).toBe("draft"); expect(pageStatusSchema.parse("published")).toBe("published"); }); });