20 lines
701 B
JavaScript
20 lines
701 B
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { compile } from "../src/compile.js";
|
|
import fixture from "../examples/esp32-audio.json" with { type: "json" };
|
|
|
|
test("compile returns svg and topology for valid model", () => {
|
|
const result = compile(fixture);
|
|
assert.equal(result.ok, true);
|
|
assert.ok(result.svg.includes("<svg"));
|
|
assert.ok(result.topology.power_domains.includes("3V3"));
|
|
assert.ok(result.topology.clock_sources.includes("U1"));
|
|
});
|
|
|
|
test("compile fails on invalid model", () => {
|
|
const bad = { symbols: {}, instances: [], nets: [] };
|
|
const result = compile(bad);
|
|
assert.equal(result.ok, false);
|
|
assert.ok(result.errors.length > 0);
|
|
});
|