This commit is contained in:
Timo Hocker
2020-04-24 17:01:26 +02:00
parent c57af9bf57
commit 3b67053b3e
12 changed files with 212 additions and 63 deletions

9
test/Color.ts Normal file
View File

@ -0,0 +1,9 @@
import test from 'ava';
import { Color } from '../lib';
test ('serialize', (t) => {
const wh = Color.white;
const tr = Color.transparent;
t.is (wh.toString (), '#ffffff');
t.is (tr.toString (), '#00000000');
});

View File

@ -1,8 +1,10 @@
import test from 'ava';
import { Edge } from '../lib';
import { Edge, Color, EdgeStyles } from '../lib';
test ('serialize', (t) => {
const e = new Edge ('foo', 'bar');
e.color = Color.white;
e.style = EdgeStyles.dashed;
const serialized = e.toString ();
t.is (serialized, 'foo -> bar');
t.is (serialized, 'foo -> bar [style="dashed",color="#ffffff"]');
});

View File

@ -1,8 +1,11 @@
import test from 'ava';
import { Graph } from '../lib';
import { Graph, GraphStyles, Color } from '../lib';
const result = `digraph foo {
subgraph cluster_foo_baz {
color = #ff0000
style = bold
foo_baz_asd [label=<asd>]
}
@ -19,6 +22,8 @@ test ('serialize', (t) => {
g.add_graph ((graph) => {
graph.name = 'baz';
graph.add_node ('asd');
graph.style = GraphStyles.bold;
graph.color = Color.red;
});
g.add_node ('baz');

View File

@ -1,15 +1,18 @@
import test from 'ava';
import { Node } from '../lib/Node';
import { NodeStyles, Node, Color } from '../lib';
const serialized_simple = 'bar_foo [label=<baz>]';
const serialized_simple
= 'bar_foo [label=<baz>,style="dashed",color="#00ff00"]';
const serialized_table = `bar_foo [label=<<table>
<tr><td>foo</td><td>bar</td><td>baz</td></tr>
<tr><td>bar</td><td>baz</td><td>foo</td></tr>
<tr><td>baz</td><td>foo</td><td>bar</td></tr>
</table>>]`;
</table>>,style="invis",color="#00ff00"]`;
test ('serialize simple', (t) => {
const g = new Node ('foo', 'bar', 'baz');
g.color = Color.green;
g.style = NodeStyles.dashed;
const serialized = g.toString ();
t.is (g.full_name, 'bar_foo');
@ -18,6 +21,8 @@ test ('serialize simple', (t) => {
test ('serialize table', (t) => {
const g = new Node ('foo', 'bar', 'baz');
g.color = Color.green;
g.style = NodeStyles.dashed;
g.table_contents = [
[