15 lines
668 B
TypeScript
15 lines
668 B
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { optionalToolReason, toolReason } from "../../.opencode/tool-reason.js";
|
|
|
|
describe("tool reason contract", () => {
|
|
it("allows omitted purpose but requires a nonblank business reason", () => {
|
|
expect(optionalToolReason.parse(undefined)).toBeUndefined();
|
|
expect(toolReason.safeParse(undefined).success).toBeFalse();
|
|
for (const schema of [optionalToolReason, toolReason]) {
|
|
expect(schema.parse(" 核验压力异常 ")).toBe("核验压力异常");
|
|
expect(schema.safeParse(" ").success).toBeFalse();
|
|
expect(schema.safeParse("x".repeat(2001)).success).toBeFalse();
|
|
}
|
|
});
|
|
});
|