import { describe, it, expect } from "vitest"; import { z } from "zod"; import { defineEvent } from "@/event-descriptor"; describe("defineEvent", () => { it("returns a descriptor with name and schema", () => { const schema = z.object({ id: z.string() }).strict(); const descriptor = defineEvent("test.thing.happened", schema); expect(descriptor.name).toBe("test.thing.happened"); expect(descriptor.schema).toBe(schema); }); it("descriptor.schema parses valid payloads", () => { const schema = z.object({ id: z.string() }).strict(); const d = defineEvent("test.evt", schema); expect(() => d.schema.parse({ id: "abc" })).not.toThrow(); }); it("descriptor.schema rejects invalid payloads", () => { const schema = z.object({ id: z.string() }).strict(); const d = defineEvent("test.evt", schema); expect(() => d.schema.parse({ id: 123 })).toThrow(); }); });