← Files DataARCHIVED FILE

tests/inline-resources.test.mjs

726 Bytes · Sep 30, 2026 · 23:19 UTC

↓ Download file

import assert from "node:assert/strict";
import test from "node:test";
import { deflateRawSync } from "node:zlib";
import { decodeBundledResource } from "../templates/data-app/inline/resources.js";

test("inline resources decode losslessly, including Unicode and SVG URLs", async () => {
  for (const value of [":host { --font: 'Écriture'; }", "data:image/svg+xml,%3csvg%20viewBox='0 0 20 20'%3e%3c/svg%3e", ""]) {
    assert.equal(await decodeBundledResource(deflateRawSync(value).toString("base64")), value);
  }
});

test("corrupt resource data rejects rather than rendering undecoded assets", async () => {
  await assert.rejects(decodeBundledResource(Buffer.from("invalid compressed resource").toString("base64")));
});

SHA-256: f4f1d53aeebb4c3424e571070e6e252b72bd4e298df90fad6920b1d23613d810