The best way to control Claude Code, Codex and more from any computer or phone

main
ts 32 lines 1.28 KB
Raw
1 import { describe, expect, test } from "bun:test";
2 import { parseOutputUrl, parseOutputValue } from "../src/DevCli.ts";
3
4 describe("parseOutputUrl", () => {
5 test("parses aligned and legacy stack output formats", () => {
6 expect(parseOutputUrl(" api http://api.localhost:1234/\n", "api")).toBe(
7 "http://api.localhost:1234/",
8 );
9 expect(parseOutputUrl('api: "https://example.com/path"\n', "api")).toBe(
10 "https://example.com/path",
11 );
12 expect(
13 parseOutputUrl('{\n api: "http://api.localhost:1234/",\n stage: "dev",\n}\n', "api"),
14 ).toBe("http://api.localhost:1234/");
15 });
16
17 test("matches exact keys and waits for a complete output line", () => {
18 expect(parseOutputUrl("otherApi http://wrong.example/\n", "api")).toBeUndefined();
19 expect(parseOutputUrl("api http://partial.example/", "api")).toBeUndefined();
20 });
21 });
22
23 describe("parseOutputValue", () => {
24 test("parses aligned and legacy scalar output formats", () => {
25 expect(parseOutputValue(" account 000000000000\n", "account")).toBe("000000000000");
26 expect(parseOutputValue('text: "seed-object-body-v1"\n', "text")).toBe("seed-object-body-v1");
27 });
28
29 test("matches exact keys", () => {
30 expect(parseOutputValue("seedAccount 000000000000\n", "account")).toBe(undefined);
31 });
32 });