Skip to content

Commit

Permalink
add test/simple-nodes-names-equal-to-javascript-object-properties.js
Browse files Browse the repository at this point in the history
  • Loading branch information
magjac committed Feb 10, 2024
1 parent e812ea5 commit 4aaf962
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/simple-nodes-names-equal-to-javascript-object-properties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import assert from "assert";
import it from "./it.js";
import jsdom from "./jsdom.js";
import * as d3 from "d3-selection";
import * as d3_graphviz from "../index.js";

it("Simple rendering an SVG from graphviz DOT.", async () => {
var window = global.window = jsdom('<div id="graph"></div>');
global.document = window.document;

var graphviz;

await new Promise(resolve => {
graphviz = d3_graphviz.graphviz("#graph")
.growEnteringEdges(true)
.onerror(e => {
console.log("graphviz.renderDot error:", e);
resolve(false);
})
.renderDot('digraph {constructor -> toString}', resolve);
});

assert.equal(d3.selectAll('.node').size(), 2, 'Number of nodes');
assert.equal(d3.selectAll('.edge').size(), 1, 'Number of edges');
assert.equal(d3.selectAll('ellipse').size(), 2, 'Number of ellipses');
assert.equal(d3.selectAll('polygon').size(), 2, 'Number of polygons');
assert.equal(d3.selectAll('path').size(), 1, 'Number of paths');
});

0 comments on commit 4aaf962

Please sign in to comment.