Fix subgraph issue

This commit is contained in:
Tyler Long
2018-03-17 18:12:24 +08:00
parent 015b976c28
commit 52d0605066
6 changed files with 25 additions and 8 deletions

View File

@@ -22,6 +22,17 @@ describe('when parsing ', function () {
expect(edges[0].text).toBe('')
})
it('should handle subgraph with tab indentation', function () {
const res = flow.parser.parse('graph TB\nsubgraph One\n\ta1-->a2\nend')
const subgraphs = flow.parser.yy.getSubGraphs()
expect(subgraphs.length).toBe(1)
const subgraph = subgraphs[0]
expect(subgraph.nodes.length).toBe(2)
expect(subgraph.nodes[0]).toBe('a1')
expect(subgraph.nodes[1]).toBe('a2')
expect(subgraph.title).toBe('One')
})
it('should handle angle bracket ' > ' as direction LR', function () {
const res = flow.parser.parse('graph >;A-->B;')