37 lines
669 B
TypeScript
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);
|
|
});
|