Skip to content

Commit 4ad7f0d

Browse files
TIANQIAN1238claude
andcommitted
test: add unit tests for extractMcpJson
Cover extracting the client id and parsed payload from a json:mcp block, and returning null when absent (app/mcp/utils.ts). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 89b8f26 commit 4ad7f0d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/extract-mcp-json.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { extractMcpJson } from "../app/mcp/utils";
2+
3+
describe("extractMcpJson", () => {
4+
test("extracts the client id and parsed mcp payload", () => {
5+
const content = '```json:mcp:client-1\n{"tool":"x"}\n```';
6+
expect(extractMcpJson(content)).toEqual({
7+
clientId: "client-1",
8+
mcp: { tool: "x" },
9+
});
10+
});
11+
12+
test("returns null when there is no mcp block", () => {
13+
expect(extractMcpJson("no mcp here")).toBeNull();
14+
});
15+
});

0 commit comments

Comments
 (0)