import { describe, expect, it } from "vitest"; import { COLLECTION_RE, pinLibraries, withEchoRuntime } from "@/lib/echo-runtime"; describe("echo runtime", () => { it("pins Babel standalone to v7 so JSX compiles without ES imports", () => { expect(pinLibraries('')).toContain("unpkg.com/@babel/standalone@7/babel.min.js"); expect(pinLibraries('')).toContain("@babel/standalone@7/babel.min.js"); }); it("pins lucide@latest to a UMD build", () => { expect(pinLibraries('')).toContain("lucide@0.468.0/dist/umd/lucide.min.js"); }); it("injects EchoDB for the app id right after ", () => { const out = withEchoRuntime("x", "11111111-1111-1111-1111-111111111111", "https://echo.example/"); expect(out.indexOf("data-echo-runtime")).toBeLessThan(out.indexOf("")); expect(out).toContain('"11111111-1111-1111-1111-111111111111"'); expect(out).toContain('"https://echo.example"'); }); it("only allows simple collection names", () => { expect(COLLECTION_RE.test("guestbook_messages")).toBe(true); expect(COLLECTION_RE.test("../secrets")).toBe(false); }); });