test: raise vitest coverage

This commit is contained in:
Peter Steinberger
2025-12-13 20:37:56 +00:00
parent 41dd3b11b7
commit cf28ea0d1c
10 changed files with 1433 additions and 1 deletions

12
src/agents/index.test.ts Normal file
View File

@@ -0,0 +1,12 @@
import { describe, expect, it } from "vitest";
import { getAgentSpec } from "./index.js";
describe("agents index", () => {
it("returns a spec for pi", () => {
const spec = getAgentSpec("pi");
expect(spec).toBeTruthy();
expect(spec.kind).toBe("pi");
expect(typeof spec.parseOutput).toBe("function");
});
});

View File

@@ -0,0 +1,34 @@
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { resolveBundledPiBinary } from "./pi-path.js";
describe("pi-path", () => {
it("resolves to a bundled binary path when available", () => {
const resolved = resolveBundledPiBinary();
expect(resolved === null || typeof resolved === "string").toBe(true);
if (typeof resolved === "string") {
expect(resolved).toMatch(/pi-coding-agent/);
expect(resolved).toMatch(/dist\/pi|dist\/cli\.js|bin\/tau-dev\.mjs/);
}
});
it("prefers dist/pi when present (branch coverage)", () => {
const original = fs.existsSync.bind(fs);
const spy = vi.spyOn(fs, "existsSync").mockImplementation((p) => {
const s = String(p);
if (s.endsWith(path.join("dist", "pi"))) return true;
return original(p);
});
try {
const resolved = resolveBundledPiBinary();
expect(resolved).not.toBeNull();
expect(typeof resolved).toBe("string");
expect(resolved).toMatch(/dist\/pi$/);
} finally {
spy.mockRestore();
}
});
});