This commit is contained in:
1 parent
128c5c6f4e
commit
46175efe1b
3 files changed
+253
-19
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { compile } from "../src/compile.js";
|
||||
import fixture from "../examples/esp32-audio.json" with { type: "json" };
|
||||
|
||||
@@ -51,12 +52,13 @@ test("compile default layout engine path remains stable", () => {
|
||||
test("compile accepts ELK layout flag option", () => {
|
||||
const result = compile(fixture, {
|
||||
use_elk_layout: true,
|
||||
elk_runtime_module: "__missing_elk_runtime_for_test__"
|
||||
elk_runtime_module: path.resolve(process.cwd(), "tests/fixtures/mock-elk-runtime.cjs")
|
||||
});
|
||||
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.layout_engine_requested, "elk");
|
||||
assert.equal(result.layout_engine_used, "schemeta-v2");
|
||||
assert.equal(result.layout_engine_used, "elk");
|
||||
assert.deepEqual(result.layout_warnings, []);
|
||||
});
|
||||
|
||||
test("compile ELK fallback is deterministic when runtime is unavailable", () => {
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
class MockElkRuntime {
|
||||
layoutSync(graph) {
|
||||
const children = Array.isArray(graph?.children) ? [...graph.children] : [];
|
||||
const positioned = children.map((node, idx) => {
|
||||
const col = idx % 4;
|
||||
const row = Math.floor(idx / 4);
|
||||
return {
|
||||
...node,
|
||||
x: 120 + col * 260,
|
||||
y: 100 + row * 200
|
||||
};
|
||||
});
|
||||
return {
|
||||
id: graph?.id ?? "root",
|
||||
children: positioned,
|
||||
edges: Array.isArray(graph?.edges) ? graph.edges : []
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MockElkRuntime;
|
||||
Reference in new issue
Block a user