-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
2,327 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
node_modules/ | ||
dist/ | ||
.parcel-cache/ |
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,46 @@ | ||
<!doctype html> | ||
<meta charset="utf8"> | ||
|
||
<link rel="stylesheet" href="npm:mocha/mocha.css"> | ||
|
||
<div id="mocha"></div> | ||
|
||
<script type="module"> | ||
|
||
import mocha from "mocha"; | ||
import assert from "assert"; | ||
import * as Viz from "@viz-js/viz"; | ||
|
||
mocha.setup("bdd"); | ||
|
||
describe("renderSVGElement", function() { | ||
let viz; | ||
|
||
beforeEach(async function() { | ||
viz = await Viz.instance(); | ||
}); | ||
|
||
it("works", async function() { | ||
assert.ok(viz.renderSVGElement("digraph { a -> b }")); | ||
}); | ||
|
||
it("works with the images option", function() { | ||
const svg = viz.renderSVGElement("graph { a[image=\"test.png\"] }", { | ||
images: [ | ||
{ name: "test.png", width: 300, height: 200 } | ||
] | ||
}); | ||
|
||
assert.ok(svg); | ||
|
||
const image = svg.querySelector("image"); | ||
|
||
assert.equal(image.getAttributeNS("http://www.w3.org/1999/xlink", "href"), "test.png"); | ||
assert.equal(image.getAttribute("width"), "300px"); | ||
assert.equal(image.getAttribute("height"), "200px"); | ||
}); | ||
}); | ||
|
||
mocha.run(); | ||
|
||
</script> |
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,18 @@ | ||
{ | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"serve": "parcel serve --no-cache --no-autoinstall index.html" | ||
}, | ||
"dependencies": { | ||
"@viz-js/viz": "link:../.." | ||
}, | ||
"devDependencies": { | ||
"assert": "^2.1.0", | ||
"buffer": "^6.0.3", | ||
"events": "^3.3.0", | ||
"mocha": "^10.3.0", | ||
"parcel": "^2.11.0", | ||
"stream-browserify": "^3.0.0" | ||
} | ||
} |
Oops, something went wrong.