Files
Daily-Campaign-Agent/packages/shared/tests/schemas.test.ts
T

10 lines
918 B
TypeScript

import { describe, expect, it } from "vitest";
import { apiErrorSchema, harnessEventSchema, messageInputSchema, modelConnectionInputSchema } from "../src/index.js";
describe("shared schemas", () => {
it("parses a discriminated HarnessEvent", () => expect(harnessEventSchema.parse({ eventId: "e1", sessionId: "s1", timestamp: new Date().toISOString(), sequence: 1, type: "run.started", payload: { runId: "r1" } }).type).toBe("run.started"));
it("strictly validates model config", () => expect(() => modelConnectionInputSchema.parse({ providerId: "openai", api: "bad", modelId: "x", supportsImages: false })).toThrow());
it("requires text or attachment", () => expect(() => messageInputSchema.parse({ text: "", attachmentIds: [] })).toThrow());
it("parses unified errors", () => expect(apiErrorSchema.parse({ error: { code: "X", message: "safe", requestId: "req_1", details: {} } }).error.code).toBe("X"));
});