ts-graphviz 1.2.3 → 1.2.4-dev.727d397dd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -1
- package/lib/adapter/deno/mod.d.ts +17 -0
- package/lib/adapter/deno/mod.js +33 -0
- package/lib/adapter/index.cjs +47 -0
- package/lib/adapter/index.d.ts +17 -0
- package/lib/adapter/index.js +42 -0
- package/media/adapter-state-machine.svg +1 -0
- package/package.json +111 -84
- package/README.ja.md +0 -498
- package/test/__snapshots__/class-base.test.ts.snap +0 -18
- package/test/__snapshots__/create-root-graph.spec.ts.snap +0 -200
- package/test/__snapshots__/to-dot.test.ts.snap +0 -229
- package/test/class-base.test.ts +0 -131
- package/test/create-root-graph.spec.ts +0 -292
- package/test/edge-group.test.ts +0 -96
- package/test/from-dot.test.ts +0 -58
- package/test/to-dot.test.ts +0 -112
- package/test/utils/index.ts +0 -1
- package/test/utils/to-dot.ts +0 -5
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { digraph, graph, strict, Graph, Digraph, attribute as _ } from 'ts-graphviz';
|
|
2
|
-
import { toDot } from '#test/utils';
|
|
3
|
-
|
|
4
|
-
describe('function digraph', () => {
|
|
5
|
-
it('should return Graph object, when execute digraph()', () => {
|
|
6
|
-
const g = digraph();
|
|
7
|
-
expect(g).toBeInstanceOf(Digraph);
|
|
8
|
-
expect(g.strict).toBe(false);
|
|
9
|
-
expect(g.directed).toBe(true);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe('root create function', () => {
|
|
13
|
-
test.each([
|
|
14
|
-
['id', { size: 0, id: 'id', strictMode: false, g: digraph('id') }],
|
|
15
|
-
[
|
|
16
|
-
'id with attributes',
|
|
17
|
-
{
|
|
18
|
-
size: 1,
|
|
19
|
-
id: 'id',
|
|
20
|
-
strictMode: false,
|
|
21
|
-
g: digraph('id', {
|
|
22
|
-
[_.label]: 'Label',
|
|
23
|
-
}),
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
[
|
|
27
|
-
'no parameters',
|
|
28
|
-
{
|
|
29
|
-
size: 0,
|
|
30
|
-
id: undefined,
|
|
31
|
-
strictMode: false,
|
|
32
|
-
g: digraph(),
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
[
|
|
36
|
-
'strict no parameters',
|
|
37
|
-
{
|
|
38
|
-
size: 0,
|
|
39
|
-
id: undefined,
|
|
40
|
-
strictMode: true,
|
|
41
|
-
g: strict.digraph(),
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
[
|
|
45
|
-
'no id with attributes',
|
|
46
|
-
{
|
|
47
|
-
size: 1,
|
|
48
|
-
id: undefined,
|
|
49
|
-
strictMode: false,
|
|
50
|
-
g: digraph({
|
|
51
|
-
[_.label]: 'Label',
|
|
52
|
-
}),
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
[
|
|
56
|
-
'strict with attributes',
|
|
57
|
-
{
|
|
58
|
-
size: 1,
|
|
59
|
-
id: undefined,
|
|
60
|
-
strictMode: true,
|
|
61
|
-
g: strict.digraph({
|
|
62
|
-
[_.label]: 'Label',
|
|
63
|
-
}),
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
[
|
|
67
|
-
'strict id with attributes',
|
|
68
|
-
{
|
|
69
|
-
size: 1,
|
|
70
|
-
id: 'id',
|
|
71
|
-
strictMode: true,
|
|
72
|
-
g: strict.digraph('id', {
|
|
73
|
-
[_.label]: 'Label',
|
|
74
|
-
}),
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
[
|
|
78
|
-
'strict no id with attributes',
|
|
79
|
-
{
|
|
80
|
-
size: 1,
|
|
81
|
-
id: undefined,
|
|
82
|
-
strictMode: true,
|
|
83
|
-
g: strict.digraph({
|
|
84
|
-
[_.label]: 'Label',
|
|
85
|
-
}),
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
])('%s', (_, { id, size, strictMode, g }) => {
|
|
89
|
-
expect(g.id).toBe(id);
|
|
90
|
-
expect(g.size).toBe(size);
|
|
91
|
-
expect(g.strict).toBe(strictMode);
|
|
92
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('callback style', () => {
|
|
97
|
-
const G = digraph('G', (g) => {
|
|
98
|
-
const a = g.node('aa');
|
|
99
|
-
const b = g.node('bb');
|
|
100
|
-
const c = g.node('cc');
|
|
101
|
-
g.edge([a, b, c], (e) => {
|
|
102
|
-
e.attributes.set('color', 'red');
|
|
103
|
-
});
|
|
104
|
-
g.subgraph('A', (A) => {
|
|
105
|
-
const Aa = A.node('Aaa', (n) => {
|
|
106
|
-
n.attributes.set('color', 'pink');
|
|
107
|
-
});
|
|
108
|
-
const Ab = A.node('Abb', (n) => {
|
|
109
|
-
n.attributes.set('color', 'violet');
|
|
110
|
-
});
|
|
111
|
-
const Ac = A.node('Acc');
|
|
112
|
-
A.edge([Aa.port('a'), Ab, Ac, 'E'], (e) => {
|
|
113
|
-
e.attributes.set('color', 'red');
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
const dot = toDot(G);
|
|
118
|
-
expect(dot).toMatchSnapshot();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
test('callback style, set attributes by attributes object', () => {
|
|
122
|
-
const G = digraph('G', (g) => {
|
|
123
|
-
const a = g.node('aa');
|
|
124
|
-
const b = g.node('bb');
|
|
125
|
-
const c = g.node('cc');
|
|
126
|
-
g.edge([a, b, c], {
|
|
127
|
-
[_.color]: 'red',
|
|
128
|
-
});
|
|
129
|
-
g.subgraph('A', (A) => {
|
|
130
|
-
const Aa = A.node('Aaa', {
|
|
131
|
-
[_.color]: 'pink',
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
const Ab = A.node('Abb', {
|
|
135
|
-
[_.color]: 'violet',
|
|
136
|
-
});
|
|
137
|
-
const Ac = A.node('Acc');
|
|
138
|
-
A.edge([Aa.port('a'), Ab, Ac, 'E'], {
|
|
139
|
-
[_.color]: 'red',
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
const dot = toDot(G);
|
|
144
|
-
expect(dot).toMatchSnapshot();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test('comment', () => {
|
|
148
|
-
const G = digraph('G', (g) => {
|
|
149
|
-
g.comment = 'This is directed graph.';
|
|
150
|
-
const a = g.node('aa');
|
|
151
|
-
a.comment = 'This is node a.';
|
|
152
|
-
const b = g.node('bb');
|
|
153
|
-
b.comment = 'This is node b.';
|
|
154
|
-
const c = g.node('cc');
|
|
155
|
-
c.comment = 'This is node c.';
|
|
156
|
-
g.edge([a, b, c], (e) => {
|
|
157
|
-
e.comment = 'This is edge.\nIt connects a, b and c.';
|
|
158
|
-
|
|
159
|
-
e.attributes.set('color', 'red');
|
|
160
|
-
e.attributes.comment = 'Edge line will draw with red.';
|
|
161
|
-
});
|
|
162
|
-
g.subgraph('A', (A) => {
|
|
163
|
-
A.comment = 'It is subgraph A.\nIt is not cluster';
|
|
164
|
-
A.node('Aaa', (n) => {
|
|
165
|
-
n.comment = 'This is node Aaa in subgraph A.';
|
|
166
|
-
n.attributes.comment = 'It will be filled by pink.';
|
|
167
|
-
n.attributes.set('color', 'pink');
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
const dot = toDot(G);
|
|
172
|
-
expect(dot).toMatchSnapshot();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
describe('function graph', () => {
|
|
177
|
-
it('should return Graph object, when execute graph()', () => {
|
|
178
|
-
const g = graph();
|
|
179
|
-
expect(g).toBeInstanceOf(Graph);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('script style', () => {
|
|
183
|
-
const g = digraph('G');
|
|
184
|
-
const subgraphA = g.createSubgraph('A');
|
|
185
|
-
const nodeA1 = subgraphA.createNode('A_node1');
|
|
186
|
-
const nodeA2 = subgraphA.createNode('A_node2');
|
|
187
|
-
subgraphA.createEdge([nodeA1, nodeA2]);
|
|
188
|
-
|
|
189
|
-
const subgraphB = g.createSubgraph('B');
|
|
190
|
-
const nodeB1 = subgraphB.createNode('B_node1');
|
|
191
|
-
const nodeB2 = subgraphB.createNode('B_node2');
|
|
192
|
-
subgraphA.createEdge([nodeB1, nodeB2]);
|
|
193
|
-
|
|
194
|
-
const node1 = g.createNode('node1');
|
|
195
|
-
const node2 = g.createNode('node2');
|
|
196
|
-
g.createEdge([node1, node2]);
|
|
197
|
-
const dot = toDot(g);
|
|
198
|
-
expect(dot).toMatchSnapshot();
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
test('callback style', () => {
|
|
202
|
-
const G = graph('G', (g) => {
|
|
203
|
-
const a = g.node('aa');
|
|
204
|
-
const b = g.node('bb');
|
|
205
|
-
const c = g.node('cc');
|
|
206
|
-
g.edge([a, b, c], (e) => {
|
|
207
|
-
e.attributes.set('color', 'red');
|
|
208
|
-
});
|
|
209
|
-
g.subgraph('A', (A) => {
|
|
210
|
-
const Aa = A.node('Aaa', (n) => {
|
|
211
|
-
n.attributes.set('color', 'pink');
|
|
212
|
-
});
|
|
213
|
-
const Ab = A.node('Abb', (n) => {
|
|
214
|
-
n.attributes.set('color', 'violet');
|
|
215
|
-
});
|
|
216
|
-
const Ac = A.node('Acc');
|
|
217
|
-
A.edge([Aa, Ab, Ac, A.node('hoge').port('fuga')], (e) => {
|
|
218
|
-
e.attributes.set('color', 'red');
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
A.edge([Aa.port({ port: 'a', compass: 'w' }), Ab.port({ compass: 'w' }), 'Aaa:e', 'Acc:r:e'], (e) => {
|
|
222
|
-
e.attributes.set('color', 'red');
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
const dot = toDot(G);
|
|
227
|
-
expect(dot).toMatchSnapshot();
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
test('callback style, set attributes by attributes object', () => {
|
|
231
|
-
const G = graph('G', (g) => {
|
|
232
|
-
const a = g.node('aa');
|
|
233
|
-
const b = g.node('bb');
|
|
234
|
-
const c = g.node('cc');
|
|
235
|
-
g.edge([a, b, c], {
|
|
236
|
-
[_.color]: 'red',
|
|
237
|
-
});
|
|
238
|
-
g.subgraph('A', (A) => {
|
|
239
|
-
const Aa = A.node('Aaa', {
|
|
240
|
-
[_.color]: 'pink',
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
const Ab = A.node('Abb', {
|
|
244
|
-
[_.color]: 'violet',
|
|
245
|
-
});
|
|
246
|
-
const Ac = A.node('Acc');
|
|
247
|
-
A.edge([Aa.port('a'), Ab, Ac, 'E'], {
|
|
248
|
-
[_.color]: 'red',
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
const dot = toDot(G);
|
|
253
|
-
expect(dot).toMatchSnapshot();
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
test('escape characters', () => {
|
|
257
|
-
const G = graph('G\n"', (g) => {
|
|
258
|
-
const a = g.node('a\na');
|
|
259
|
-
a.attributes.set('label', '1\n2\n"\n3');
|
|
260
|
-
const b = g.node('b"b');
|
|
261
|
-
const c = g.node('c\nc"');
|
|
262
|
-
g.edge([a, b, c], (e) => {
|
|
263
|
-
e.attributes.set('color', 'red');
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
g.subgraph('graph.name', (s) => {
|
|
267
|
-
const innerA = s.node('node.name');
|
|
268
|
-
innerA.attributes.set('label', 'node');
|
|
269
|
-
const innerB = s.node('another.name');
|
|
270
|
-
innerB.attributes.set('label', 'words with space and "quote"');
|
|
271
|
-
s.edge([innerA, innerB]);
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
const dot = toDot(G);
|
|
275
|
-
expect(dot).toMatchSnapshot();
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
describe('strict mode', () => {
|
|
280
|
-
it('should return Digraph object, when execute digraph()', () => {
|
|
281
|
-
const g = strict.digraph();
|
|
282
|
-
expect(g).toBeInstanceOf(Digraph);
|
|
283
|
-
expect(g.strict).toBe(true);
|
|
284
|
-
expect(g.directed).toBe(true);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it('should return Graph object, when execute graph()', () => {
|
|
288
|
-
const g = strict.graph();
|
|
289
|
-
expect(g).toBeInstanceOf(Graph);
|
|
290
|
-
expect(g.strict).toBe(true);
|
|
291
|
-
});
|
|
292
|
-
});
|
package/test/edge-group.test.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { digraph } from 'ts-graphviz';
|
|
2
|
-
import { fromModel } from 'ts-graphviz/ast';
|
|
3
|
-
|
|
4
|
-
import { toDot } from '#test/utils';
|
|
5
|
-
|
|
6
|
-
test('edge group', () => {
|
|
7
|
-
expect(
|
|
8
|
-
fromModel(
|
|
9
|
-
digraph((g) => {
|
|
10
|
-
g.edge(['a', ['b', 'c']]);
|
|
11
|
-
}),
|
|
12
|
-
),
|
|
13
|
-
).toMatchInlineSnapshot(`
|
|
14
|
-
Object {
|
|
15
|
-
"children": Array [
|
|
16
|
-
Object {
|
|
17
|
-
"children": Array [
|
|
18
|
-
Object {
|
|
19
|
-
"children": Array [],
|
|
20
|
-
"location": null,
|
|
21
|
-
"targets": Array [
|
|
22
|
-
Object {
|
|
23
|
-
"children": Array [],
|
|
24
|
-
"compass": undefined,
|
|
25
|
-
"id": Object {
|
|
26
|
-
"children": Array [],
|
|
27
|
-
"location": null,
|
|
28
|
-
"quoted": true,
|
|
29
|
-
"type": "Literal",
|
|
30
|
-
"value": "a",
|
|
31
|
-
},
|
|
32
|
-
"location": null,
|
|
33
|
-
"port": undefined,
|
|
34
|
-
"type": "NodeRef",
|
|
35
|
-
},
|
|
36
|
-
Object {
|
|
37
|
-
"children": Array [
|
|
38
|
-
Object {
|
|
39
|
-
"children": Array [],
|
|
40
|
-
"compass": undefined,
|
|
41
|
-
"id": Object {
|
|
42
|
-
"children": Array [],
|
|
43
|
-
"location": null,
|
|
44
|
-
"quoted": true,
|
|
45
|
-
"type": "Literal",
|
|
46
|
-
"value": "b",
|
|
47
|
-
},
|
|
48
|
-
"location": null,
|
|
49
|
-
"port": undefined,
|
|
50
|
-
"type": "NodeRef",
|
|
51
|
-
},
|
|
52
|
-
Object {
|
|
53
|
-
"children": Array [],
|
|
54
|
-
"compass": undefined,
|
|
55
|
-
"id": Object {
|
|
56
|
-
"children": Array [],
|
|
57
|
-
"location": null,
|
|
58
|
-
"quoted": true,
|
|
59
|
-
"type": "Literal",
|
|
60
|
-
"value": "c",
|
|
61
|
-
},
|
|
62
|
-
"location": null,
|
|
63
|
-
"port": undefined,
|
|
64
|
-
"type": "NodeRef",
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
"location": null,
|
|
68
|
-
"type": "NodeRefGroup",
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
"type": "Edge",
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
"directed": true,
|
|
75
|
-
"id": undefined,
|
|
76
|
-
"location": null,
|
|
77
|
-
"strict": false,
|
|
78
|
-
"type": "Graph",
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
"location": null,
|
|
82
|
-
"type": "Dot",
|
|
83
|
-
}
|
|
84
|
-
`);
|
|
85
|
-
expect(
|
|
86
|
-
toDot(
|
|
87
|
-
digraph((g) => {
|
|
88
|
-
g.edge(['a', ['b', 'c']]);
|
|
89
|
-
}),
|
|
90
|
-
),
|
|
91
|
-
).toMatchInlineSnapshot(`
|
|
92
|
-
digraph {
|
|
93
|
-
"a" -> {"b" "c"};
|
|
94
|
-
}
|
|
95
|
-
`);
|
|
96
|
-
});
|
package/test/from-dot.test.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Digraph, Edge, Node, RootGraph, Subgraph, fromDot } from 'ts-graphviz';
|
|
2
|
-
import { toDot } from '#test/utils';
|
|
3
|
-
|
|
4
|
-
describe('fromDot function', () => {
|
|
5
|
-
test('RootGraph', () => {
|
|
6
|
-
const G = fromDot('digraph {}');
|
|
7
|
-
expect(G).toBeInstanceOf(RootGraph);
|
|
8
|
-
expect(G).toBeInstanceOf(Digraph);
|
|
9
|
-
expect(G.strict).toStrictEqual(false);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('Node', () => {
|
|
13
|
-
const node = fromDot('a[ label = hoge]', { parse: { startRule: 'Node' } });
|
|
14
|
-
expect(node).toBeInstanceOf(Node);
|
|
15
|
-
expect(node.id).toStrictEqual('a');
|
|
16
|
-
expect(node.attributes.get('label')).toStrictEqual('hoge');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('Edge', () => {
|
|
20
|
-
const edge = fromDot('a -> b [ label = hoge]', { parse: { startRule: 'Edge' } });
|
|
21
|
-
expect(edge).toBeInstanceOf(Edge);
|
|
22
|
-
expect(edge.targets).toMatchObject([{ id: 'a' }, { id: 'b' }]);
|
|
23
|
-
expect(edge.attributes.get('label')).toStrictEqual('hoge');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('Subgraph', () => {
|
|
27
|
-
const subgraph = fromDot(
|
|
28
|
-
`subgraph sub {
|
|
29
|
-
label = hoge;
|
|
30
|
-
}`,
|
|
31
|
-
{ parse: { startRule: 'Subgraph' } },
|
|
32
|
-
);
|
|
33
|
-
expect(subgraph).toBeInstanceOf(Subgraph);
|
|
34
|
-
expect(subgraph.id).toStrictEqual('sub');
|
|
35
|
-
expect(subgraph.get('label')).toStrictEqual('hoge');
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('partially described by DOT', () => {
|
|
40
|
-
const G = fromDot(
|
|
41
|
-
`digraph {
|
|
42
|
-
node_A [
|
|
43
|
-
label = "This is a Label of Node A";
|
|
44
|
-
];
|
|
45
|
-
}`,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
G.edge(['node_A', 'node_B']);
|
|
49
|
-
|
|
50
|
-
expect(toDot(G)).toMatchInlineSnapshot(`
|
|
51
|
-
digraph {
|
|
52
|
-
"node_A" [
|
|
53
|
-
label = "This is a Label of Node A";
|
|
54
|
-
];
|
|
55
|
-
"node_A" -> "node_B";
|
|
56
|
-
}
|
|
57
|
-
`);
|
|
58
|
-
});
|
package/test/to-dot.test.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { RootGraphModel, Digraph, Graph, attribute as _ } from 'ts-graphviz';
|
|
2
|
-
import { toDot } from '#test/utils';
|
|
3
|
-
|
|
4
|
-
describe.each([
|
|
5
|
-
['Digraph', () => new Digraph()],
|
|
6
|
-
['Graph', () => new Graph()],
|
|
7
|
-
])('%s', (__, rootClusterFactory) => {
|
|
8
|
-
let g: RootGraphModel;
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
g = rootClusterFactory();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe('renders correctly by toDot method', () => {
|
|
14
|
-
it('simple g', () => {
|
|
15
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('strict graph', () => {
|
|
19
|
-
g.strict = true;
|
|
20
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('set attributes', () => {
|
|
24
|
-
g.set(_.dpi, 360);
|
|
25
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('set attributes by apply', () => {
|
|
29
|
-
g.apply({
|
|
30
|
-
[_.layout]: 'dot',
|
|
31
|
-
[_.dpi]: 360,
|
|
32
|
-
});
|
|
33
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('digraph with comment', () => {
|
|
37
|
-
test('single line comment', () => {
|
|
38
|
-
g.comment = 'this is comment.';
|
|
39
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('multi line comment', () => {
|
|
43
|
-
g.comment = 'this is comment.\nsecond line.';
|
|
44
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('has some attributes', () => {
|
|
49
|
-
g.attributes.edge.set(_.label, 'edge label');
|
|
50
|
-
g.attributes.graph.set(_.color, 'red');
|
|
51
|
-
g.attributes.node.set(_.xlabel, 'node xlabel');
|
|
52
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('nodes and edge', () => {
|
|
56
|
-
const node1 = g.createNode('node1');
|
|
57
|
-
const node2 = g.createNode('node2');
|
|
58
|
-
g.createEdge([node1, node2]);
|
|
59
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('subgraphs', () => {
|
|
63
|
-
const subgraphA = g.createSubgraph('A');
|
|
64
|
-
const nodeA1 = subgraphA.createNode('A_node1');
|
|
65
|
-
const nodeA2 = subgraphA.createNode('A_node2');
|
|
66
|
-
subgraphA.createEdge([nodeA1, nodeA2]);
|
|
67
|
-
|
|
68
|
-
const subgraphB = g.createSubgraph('B');
|
|
69
|
-
const nodeB1 = subgraphB.createNode('B_node1');
|
|
70
|
-
const nodeB2 = subgraphB.createNode('B_node2');
|
|
71
|
-
subgraphA.createEdge([nodeB1, nodeB2]);
|
|
72
|
-
|
|
73
|
-
const node1 = g.createNode('node1');
|
|
74
|
-
const node2 = g.createNode('node2');
|
|
75
|
-
g.createEdge([node1, node2]);
|
|
76
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('subgraphs, depth 2', () => {
|
|
80
|
-
const subgraphDepth1 = g.createSubgraph('depth1');
|
|
81
|
-
const nodeA1 = subgraphDepth1.createNode('depth1_node1');
|
|
82
|
-
const nodeA2 = subgraphDepth1.createNode('depth1_node2');
|
|
83
|
-
subgraphDepth1.createEdge([nodeA1, nodeA2]);
|
|
84
|
-
|
|
85
|
-
const subgraphDepth2 = subgraphDepth1.createSubgraph('depth2');
|
|
86
|
-
const nodeB1 = subgraphDepth2.createNode('depth2_node1');
|
|
87
|
-
const nodeB2 = subgraphDepth2.createNode('depth2_node2');
|
|
88
|
-
subgraphDepth2.createEdge([nodeB1, nodeB2]);
|
|
89
|
-
|
|
90
|
-
const node1 = g.createNode('node1');
|
|
91
|
-
const node2 = g.createNode('node2');
|
|
92
|
-
g.createEdge([node1, node2]);
|
|
93
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
describe('label attribute behavior', () => {
|
|
97
|
-
it('plain text label to be quoted by double quotation', () => {
|
|
98
|
-
g.attributes.graph.set(_.label, 'this is test for graph label');
|
|
99
|
-
g.attributes.edge.set(_.label, 'this is test for edge label');
|
|
100
|
-
g.attributes.node.set(_.label, 'this is test for node label');
|
|
101
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('html like', () => {
|
|
105
|
-
g.attributes.graph.set(_.label, '<<B>this is test for graph label</B>>');
|
|
106
|
-
g.attributes.edge.set(_.label, '<<U>this is test for edge label</U>>');
|
|
107
|
-
g.attributes.node.set(_.label, '<<I>this is test for node label</I>>');
|
|
108
|
-
expect(toDot(g)).toMatchSnapshot();
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
package/test/utils/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './to-dot.js';
|