2020-04-24 14:05:58 +02:00

32 lines
546 B
TypeScript

import test from 'ava';
import { Graph } from '../lib';
const result = `digraph foo {
subgraph cluster_foo_baz {
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');
});
g.add_node ('baz');
g.add_node ('foo');
g.add_edge ('foo', 'baz');
const serialized = g.toString ();
t.is (serialized, result);
});