test: raise vitest coverage
This commit is contained in:
12
src/agents/index.test.ts
Normal file
12
src/agents/index.test.ts
Normal 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");
|
||||
});
|
||||
});
|
||||
34
src/agents/pi-path.test.ts
Normal file
34
src/agents/pi-path.test.ts
Normal 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();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user