Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { describe, expect, it } from "@suaveplan/testing/runner";
import { composeAbiShimmedSource } from "./abi-shim.js";
describe("composeAbiShimmedSource", () => {
it("appends the shim suffix and includes the protocol-version header", {
timeout: 5000,
}, () => {
const { js } = composeAbiShimmedSource({
bundledJs:
"var plugin = { routes: [], handleRequest: async () => null };",
});
expect(js.includes("wasi-stdio v1")).toBe(true);
expect(js.includes("Javy.IO.readSync")).toBe(true);
expect(js.includes("Javy.IO.writeSync")).toBe(true);
expect(js.includes("plugin.handleRequest")).toBe(true);
expect(js.includes("plugin.routes")).toBe(true);
});
it("is byte-stable for identical inputs", { timeout: 5000 }, () => {
const input =
"var plugin = { routes: [{ method:'GET', path:'/h' }], handleRequest: async () => ({ status:200, headers:[], bodyBase64:'' }) };";
const a = composeAbiShimmedSource({ bundledJs: input });
const b = composeAbiShimmedSource({ bundledJs: input });
expect(a.js).toBe(b.js);
});
it("handles each of the four kinds in the shim", { timeout: 5000 }, () => {
const { js } = composeAbiShimmedSource({
bundledJs: "var plugin = {};",
});
expect(js.includes("'routes'")).toBe(true);
expect(js.includes("'start'")).toBe(true);
expect(js.includes("'dispose'")).toBe(true);
expect(js.includes("'request'")).toBe(true);
expect(js.includes("'error'")).toBe(true);
});
});