Initial Commit
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user