2020-04-24 12:21:26 +02:00

33 lines
587 B
TypeScript

import test from 'ava';
import { Graph, Node } from '../lib';
const result = `digraph foo {
subgraph cluster_foo_baz {
foo_baz_asd
}
foo_baz
foo_foo
foo_foo -> foo_baz
}`;
test ('serialize', (t) => {
const g = new Graph ('foo');
t.is (g.full_name, 'foo');
g.add_graph (() => {
const graph = new Graph ('baz');
graph.add_node (() => new Node ('asd'));
return graph;
});
g.add_node (() => new Node ('baz'));
g.add_node (() => new Node ('foo'));
g.add_edge ('foo', 'baz');
const serialized = g.toString ();
t.is (serialized, result);
});