-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test/simple-nodes-names-equal-to-javascript-object-properties.js
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
test/simple-nodes-names-equal-to-javascript-object-properties.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); |