Files
short-video-viral-replicator/agent-studio-mini/packages/shared/tests/schemas.test.ts
T

40 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
ApiErrorSchema,
HarnessEventSchema,
MessageInputSchema,
ModelConnectionInputSchema,
} from "../src/index.js";
describe("shared schemas", () => {
it("validates a harness event", () =>
expect(
HarnessEventSchema.parse({
eventId: "e",
sessionId: "s",
timestamp: new Date().toISOString(),
sequence: 1,
type: "run.started",
payload: {},
}).type,
).toBe("run.started"));
it("requires message content", () =>
expect(() =>
MessageInputSchema.parse({ text: " ", attachmentIds: [] }),
).toThrow());
it("strictly validates model config", () =>
expect(() =>
ModelConnectionInputSchema.parse({
providerId: "p",
api: "bad",
modelId: "m",
supportsImages: false,
}),
).toThrow());
it("validates unified errors", () =>
expect(
ApiErrorSchema.parse({
error: { code: "X", message: "x", requestId: "r", details: {} },
}).error.code,
).toBe("X"));
});