font.test.ts

755 B · typescript · 16 lines

1import { expect, test } from "bun:test";2import { existsSync } from "node:fs";3import { join } from "node:path";4import { animate, cycle } from "./kit/ui/font.js";56const pkg = join(import.meta.dir, "pkg");78test("the kit's font choreography matches the crate frame for frame", async () => {9  if (!existsSync(join(pkg, "mrlydemo.js"))) return;10  const wasm = await import(join(pkg, "mrlydemo.js"));11  await wasm.default({ module_or_path: await Bun.file(join(pkg, "mrlydemo_bg.wasm")).arrayBuffer() });12  for (const text of ["MRLYPROD", "SIERPINSKI", "mrly.net", "(1)", "Hi 42", "A"]) {13    expect(animate(text, 1)).toEqual(JSON.parse(wasm.font_animate(text, 1)));14    expect(cycle(text, 1, 25)).toEqual(JSON.parse(wasm.font_cycle(text, 1, 25)));15  }16});