Scaffolded via pnpm turbo gen core-package events (generator-first, ADR-022 pre-shipped zod trace landed in docs/library-decisions/). Generator wired transpilePackages + E1/J eslint rule block. Two story-00-precedent additions so the coverage gates pass: the @vitest/coverage-v8 devDep (L0 sweep) and the honest symbols.ts exclude (mirroring core-shared/vitest.config.ts) plus its missing ALLOWED_GLOBS mirror in scripts/coverage/diff.mjs (L1 gate). No consumers wired — compile-green floor for the walking-skeleton PRD (ADR-027). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
25 lines
908 B
TypeScript
25 lines
908 B
TypeScript
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();
|
|
});
|
|
});
|