feat: add logger and twilio poll backoff
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { parseClaudeJsonText } from "./claude.js";
|
||||
import { parseClaudeJson, parseClaudeJsonText } from "./claude.js";
|
||||
|
||||
describe("claude JSON parsing", () => {
|
||||
it("extracts text from single JSON object", () => {
|
||||
@@ -16,5 +16,17 @@ describe("claude JSON parsing", () => {
|
||||
it("returns undefined on invalid JSON", () => {
|
||||
expect(parseClaudeJsonText("not json")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("extracts text from Claude CLI result field and preserves metadata", () => {
|
||||
const sample = {
|
||||
type: "result",
|
||||
subtype: "success",
|
||||
result: "hello from result field",
|
||||
duration_ms: 1234,
|
||||
usage: { server_tool_use: { tool_a: 2 } },
|
||||
};
|
||||
const parsed = parseClaudeJson(JSON.stringify(sample));
|
||||
expect(parsed?.text).toBe("hello from result field");
|
||||
expect(parsed?.parsed).toMatchObject({ duration_ms: 1234 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user