Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

extensions/fast/__tests__/harness.test.ts

Raw
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { createTestSession, type TestSession } from "../../../test/harness";
import { _test } from "../index.ts";

describe("fast pi-test-harness", () => {
	let t: TestSession | undefined;

	afterEach(() => {
		t?.dispose();
		t = undefined;
	});

	it("loads in real Pi extension runtime", async () => {
		const extensionPath = path.resolve(import.meta.dirname, "../index.ts");
		t = await createTestSession({ extensions: [extensionPath] });

		expect(t.session.extensionRunner.extensions).toHaveLength(1);
		expect(t.session.extensionRunner.extensions[0].path).toBe(extensionPath);
	});

	it("owns fast activation", () => {
		expect(
			_test.fastActive({ model: { provider: "openai-codex" } } as any, true),
		).toBe(true);
		expect(
			_test.fastActive({ model: { provider: "openai" } } as any, true),
		).toBe(false);
		expect(
			_test.fastActive({ model: { provider: "openai-codex" } } as any, false),
		).toBe(false);
	});
});