repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by bugabinga
extensions/devil/__tests__/harness.test.ts
RawFile outline
import { fileURLToPath } from "node:url";
import { afterEach, describe, expect, it } from "vitest";
import { createTestSession, type TestSession } from "../../../test/harness";
let t: TestSession | undefined;
function devilPath(): string {
return fileURLToPath(new URL("../index.ts", import.meta.url));
}
afterEach(() => {
t?.dispose();
t = undefined;
});
describe("devil harness integration", () => {
it("loads in real Pi extension runtime and registers command/flags", async () => {
t = await createTestSession({ extensions: [devilPath()] });
const [extension] = t.session.extensionRunner.extensions;
expect(extension.commands.has("devil")).toBe(true);
expect(extension.flags.has("devil-rounds")).toBe(true);
expect(extension.flags.has("devil-stop")).toBe(true);
});
it("handles empty /devil command through real command dispatch", async () => {
t = await createTestSession({ extensions: [devilPath()] });
await t.session.prompt("/devil");
const notify = t.events.uiCallsFor("notify");
expect(notify).toHaveLength(1);
expect(notify[0].args).toEqual(["Usage: /devil <your idea>", "error"]);
});
});