2020-04-24 12:02:32 +02:00

45 lines
907 B
TypeScript

import test from 'ava';
import { Node } from '../lib/Node';
const serialized_simple = 'bar_foo [label=<baz>]';
const serialized_table = `bar_foo [label=<<table>
<tr><td>foo</td><td>bar</td><td>baz</td></tr>
<tr><td>bar</td><td>baz</td><td>foo</td></tr>
<tr><td>baz</td><td>foo</td><td>bar</td></tr>
</table>>]`;
test ('serialize simple', (t) => {
const g = new Node ('foo', 'bar', 'baz');
const serialized = g.toString ();
t.is (g.full_name, 'bar_foo');
t.is (serialized, serialized_simple);
});
test ('serialize table', (t) => {
const g = new Node ('foo', 'bar', 'baz');
g.table_contents = [
[
'foo',
'bar',
'baz'
],
[
'bar',
'baz',
'foo'
],
[
'baz',
'foo',
'bar'
]
];
g.is_table = true;
const serialized = g.toString ();
t.is (g.full_name, 'bar_foo');
t.is (serialized, serialized_table);
});