mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-11 12:51:15 +02:00
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { parseOutputUrl, parseOutputValue } from "../src/DevCli.ts";
|
|
|
|
describe("parseOutputUrl", () => {
|
|
test("parses aligned and legacy stack output formats", () => {
|
|
expect(
|
|
parseOutputUrl(" api http://api.localhost:1234/\n", "api"),
|
|
).toBe("http://api.localhost:1234/");
|
|
expect(parseOutputUrl('api: "https://example.com/path"\n', "api")).toBe(
|
|
"https://example.com/path",
|
|
);
|
|
expect(
|
|
parseOutputUrl(
|
|
'{\n api: "http://api.localhost:1234/",\n stage: "dev",\n}\n',
|
|
"api",
|
|
),
|
|
).toBe("http://api.localhost:1234/");
|
|
});
|
|
|
|
test("matches exact keys and waits for a complete output line", () => {
|
|
expect(
|
|
parseOutputUrl("otherApi http://wrong.example/\n", "api"),
|
|
).toBeUndefined();
|
|
expect(
|
|
parseOutputUrl("api http://partial.example/", "api"),
|
|
).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("parseOutputValue", () => {
|
|
test("parses aligned and legacy scalar output formats", () => {
|
|
expect(parseOutputValue(" account 000000000000\n", "account")).toBe(
|
|
"000000000000",
|
|
);
|
|
expect(parseOutputValue('text: "seed-object-body-v1"\n', "text")).toBe(
|
|
"seed-object-body-v1",
|
|
);
|
|
});
|
|
|
|
test("matches exact keys", () => {
|
|
expect(parseOutputValue("seedAccount 000000000000\n", "account")).toBe(
|
|
undefined,
|
|
);
|
|
});
|
|
});
|