repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/usage/__tests__/harness.test.ts

Raw
File outline
import { afterEach, describe, expect, it } from "vitest";
import { createTestSession, type TestSession } from "../../../test/harness";
import usageExtension from "../index";

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

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

	it("loads in real Pi extension runtime", async () => {
		t = await createTestSession({ extensionFactories: [usageExtension] });

		expect(t.session.extensionRunner.extensions).toHaveLength(1);
	});

	it("loads the dashboard implementation on first command use", async () => {
		t = await createTestSession({ extensionFactories: [usageExtension] });
		const command =
			t.session.extensionRunner.extensions[0].commands.get("usage");

		await expect(command.handler("", { hasUI: false } as never)).resolves.toBe(
			undefined,
		);
	});
});