import test from "node:test";
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { compile } from "../src/compile.js";
import fixture from "../examples/esp32-audio.json" with { type: "json" };

function svgHash(svg) {
  return createHash("sha256").update(String(svg ?? "")).digest("hex");
}

test("render output for reference fixture remains deterministic", () => {
  const outA = compile(fixture, { render_mode: "schematic_stub", show_labels: true });
  const outB = compile(fixture, { render_mode: "schematic_stub", show_labels: true });

  assert.equal(outA.ok, true);
  assert.equal(outB.ok, true);
  assert.equal(outA.svg, outB.svg);
  assert.equal(svgHash(outA.svg), "fe431f62be90da91fbd707e1d2dae9286a04d61442893fa54fbebb048c748841");
});
