Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

extensions/decay/__tests__/contract.test.ts

Raw
import { fileURLToPath } from "node:url";
import { afterEach, describe, expect, it } from "vitest";
import {
	createPiSession,
	type PiSession,
} from "../../../test/fixture/create-pi-session.ts";

let session: PiSession | undefined;

afterEach(async () => {
	await session?.dispose();
	session = undefined;
});

describe("decay contract", () => {
	it("loads through the owned fixture and registers its compaction handler", async () => {
		session = await createPiSession({
			extensionPaths: [fileURLToPath(new URL("../index.ts", import.meta.url))],
		});

		expect(session.errors).toEqual([]);
		expect(session.extensions).toHaveLength(1);
		expect(
			session.session.extensionRunner.hasHandlers("session_before_compact"),
		).toBe(true);
	});
});