Timo Hocker 3b67053b3e styles
2020-04-24 17:01:26 +02:00

37 lines
669 B
TypeScript

import test from 'ava';
import { Graph, GraphStyles, Color } from '../lib';
const result = `digraph foo {
subgraph cluster_foo_baz {
color = #ff0000
style = bold
foo_baz_asd [label=<asd>]
}
foo_baz [label=<baz>]
foo_foo [label=<foo>]
foo_foo -> foo_baz
}`;
test ('serialize', (t) => {
const g = new Graph ('foo');
t.is (g.full_name, 'foo');
g.add_graph ((graph) => {
graph.name = 'baz';
graph.add_node ('asd');
graph.style = GraphStyles.bold;
graph.color = Color.red;
});
g.add_node ('baz');
g.add_node ('foo');
g.add_edge ('foo', 'baz');
const serialized = g.toString ();
t.is (serialized, result);
});