/** * Load smoke test. * * Pi loads extensions with Node's strip-only TypeScript mode, which rejects * some perfectly valid TS (constructor parameter properties, enums, namespaces). * tsc is happy with all of them, so a typecheck does NOT catch this class of * bug -- only actually importing the entrypoint the way pi does. * * This caught `constructor(private readonly x)` in image-component.ts, which * would have shipped as an extension that fails to load. */ import assert from "node:assert/strict"; import { test } from "node:test"; test("the extension entrypoint imports under strip-only TypeScript", async () => { const module = await import("../src/index.ts"); assert.equal(typeof module.default, "function", "extension must default-export a function"); }); test("registration wires up every command, shortcut, hook and renderer", async () => { const module = await import("../src/index.ts"); const registered: string[] = []; module.default({ on: (event: string) => registered.push(`on:${event}`), registerCommand: (name: string) => registered.push(`cmd:${name}`), registerShortcut: (key: string) => registered.push(`key:${key}`), registerEntryRenderer: (type: string) => registered.push(`renderer:${type}`), } as never); // Attach paths. assert.ok(registered.includes("cmd:paste")); assert.ok(registered.includes("cmd:image")); assert.ok(registered.includes("key:ctrl+v")); // Inline rendering and the marker swap. assert.ok(registered.includes("renderer:wl-image")); assert.ok(registered.includes("on:input")); // Cell size resolution, and freeing images from the terminal on exit. assert.ok(registered.includes("on:session_start")); assert.ok(registered.includes("on:session_shutdown")); });