33 lines
587 B
TypeScript
Raw Normal View History

2020-04-24 12:02:32 +02:00
import test from 'ava';
import { Graph, Node } from '../lib';
2020-04-24 12:21:26 +02:00
const result = `digraph foo {
subgraph cluster_foo_baz {
foo_baz_asd
2020-04-24 12:02:32 +02:00
}
2020-04-24 12:21:26 +02:00
foo_baz
foo_foo
2020-04-24 12:02:32 +02:00
2020-04-24 12:21:26 +02:00
foo_foo -> foo_baz
2020-04-24 12:02:32 +02:00
}`;
test ('serialize', (t) => {
2020-04-24 12:21:26 +02:00
const g = new Graph ('foo');
2020-04-24 12:02:32 +02:00
2020-04-24 12:21:26 +02:00
t.is (g.full_name, 'foo');
2020-04-24 12:02:32 +02:00
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);
});