mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 00:09:51 +02:00
#457 Added grammar for double directional arrows
This commit is contained in:
@@ -36,45 +36,45 @@
|
||||
"," return 'COMMA';
|
||||
"*" return 'MULT';
|
||||
\s*\-\-[x]\s* return 'ARROW_CROSS';
|
||||
\s*[x]\-\-[x]\s* return 'DOUBLE_ARROW_CROSS';
|
||||
\s*\-\-\>\s* return 'ARROW_POINT';
|
||||
\s*\<\-\-\>\s* return 'DOUBLE_ARROW_POINT';
|
||||
\s*\-\-[o]\s* return 'ARROW_CIRCLE';
|
||||
\s*[x]\-\-[x]\s* return 'DOUBLE_ARROW_CROSS';
|
||||
\s*[o]\-\-[o]\s* return 'DOUBLE_ARROW_CIRCLE';
|
||||
\s*[o]\.\-[o]\s* return 'DOUBLE_DOTTED_ARROW_CIRCLE';
|
||||
\s*\<\=\=\>\s* return 'DOUBLE_THICK_ARROW_POINT';
|
||||
\s*[o]\=\=[o]\s* return 'DOUBLE_THICK_ARROW_CIRCLE';
|
||||
\s*[x]\=\=[x]\s* return 'DOUBLE_THICK_ARROW_CROSS';
|
||||
\s*[x].\-[x]\s* return 'DOUBLE_DOTTED_ARROW_CROSS';
|
||||
\s*[x]\-\.\-[x]\s* return 'DOUBLE_DOTTED_ARROW_CROSS';
|
||||
\s*\<\.\-\>\s* return 'DOUBLE_DOTTED_ARROW_POINT';
|
||||
\s*\<\-\.\-\>\s* return 'DOUBLE_DOTTED_ARROW_POINT';
|
||||
\s*[o]\-\.\-[o]\s* return 'DOUBLE_DOTTED_ARROW_CIRCLE';
|
||||
\s*\-\-[o]\s* return 'ARROW_CIRCLE';
|
||||
\s*\-\-\-\s* return 'ARROW_OPEN';
|
||||
\s*\-\.\-[x]\s* return 'DOTTED_ARROW_CROSS';
|
||||
\s*[x]\-\.\-[x]\s* return 'DOUBLE_DOTTED_ARROW_CROSS';
|
||||
\s*\-\.\-\>\s* return 'DOTTED_ARROW_POINT';
|
||||
\s*\<\-\.\-\>\s* return 'DOUBLE_DOTTED_ARROW_POINT';
|
||||
\s*\-\.\-[o]\s* return 'DOTTED_ARROW_CIRCLE';
|
||||
\s*[o]\-\.\-[o]\s* return 'DOUBLE_DOTTED_ARROW_CIRCLE';
|
||||
\s*\-\.\-\s* return 'DOTTED_ARROW_OPEN';
|
||||
\s*.\-[x]\s* return 'DOTTED_ARROW_CROSS';
|
||||
\s*[x].\-[x]\s* return 'DOUBLE_DOTTED_ARROW_CROSS';
|
||||
\s*\.\-\>\s* return 'DOTTED_ARROW_POINT';
|
||||
\s*\<\.\-\>\s* return 'DOUBLE_DOTTED_ARROW_POINT';
|
||||
\s*\.\-[o]\s* return 'DOTTED_ARROW_CIRCLE';
|
||||
\s*[o]\.\-[o]\s* return 'DOUBLE_DOTTED_ARROW_CIRCLE';
|
||||
\s*\.\-\s* return 'DOTTED_ARROW_OPEN';
|
||||
\s*\=\=[x]\s* return 'THICK_ARROW_CROSS';
|
||||
\s*[x]\=\=[x]\s* return 'DOUBLE_THICK_ARROW_CROSS';
|
||||
\s*\=\=\>\s* return 'THICK_ARROW_POINT';
|
||||
\s*\<\=\=\>\s* return 'DOUBLE_THICK_ARROW_POINT';
|
||||
\s*\=\=[o]\s* return 'THICK_ARROW_CIRCLE';
|
||||
\s*[o]\=\=[o]\s* return 'DOUBLE_THICK_ARROW_CIRCLE';
|
||||
\s*\=\=[\=]\s* return 'THICK_ARROW_OPEN';
|
||||
\s*\<\-\-\s* return 'START_DOUBLE_ARROW_POINT';
|
||||
\s*[x]\-\-\s* return 'START_DOUBLE_ARROW_CROSS';
|
||||
\s*[o]\-\-\s* return 'START_DOUBLE_ARROW_CIRCLE';
|
||||
\s*\<\-\.\s* return 'START_DOUBLE_DOTTED_ARROW_POINT';
|
||||
\s*[x]\-\.\s* return 'START_DOUBLE_DOTTED_ARROW_CROSS';
|
||||
\s*[o]\-\.\s* return 'START_DOUBLE_DOTTED_ARROW_CIRCLE';
|
||||
\s*\<\=\=\s* return 'START_DOUBLE_THICK_ARROW_POINT';
|
||||
\s*[x]\=\=\s* return 'START_DOUBLE_THICK_ARROW_CROSS';
|
||||
\s*[o]\=\=\s* return 'START_DOUBLE_THICK_ARROW_CIRCLE';
|
||||
\s*\-\-\s* return '--';
|
||||
\s*\-\.\s* return '-.';
|
||||
\s*\=\=\s* return '==';
|
||||
\s*\<\-\-\s* return 'START_DOUBLE_ARROW_POINT';
|
||||
\s*\[x]\-\-\s* return 'START_DOUBLE_ARROW_CROSS';
|
||||
\s*\[o]\-\-\s* return 'START_DOUBLE_ARROW_CIRCLE';
|
||||
\s*\<\-\.\s* return 'START_DOUBLE_DOTTED_ARROW_POINT';
|
||||
\s*\[x]\-\.\s* return 'START_DOUBLE_DOTTED_ARROW_CROSS';
|
||||
\s*\[o]\-\.\s* return 'START_DOUBLE_DOTTED_ARROW_CIRCLE';
|
||||
\s*\<\=\=\s* return 'START_DOUBLE_THICK_ARROW_POINT';
|
||||
\s*\[x]\=\=\s* return 'START_DOUBLE_THICK_ARROW_CROSS';
|
||||
\s*\[o]\=\=\s* return 'START_DOUBLE_THICK_ARROW_CIRCLE';
|
||||
"(-" return '(-';
|
||||
"-)" return '-)';
|
||||
\- return 'MINUS';
|
||||
@@ -331,50 +331,84 @@ link: linkStatement arrowText
|
||||
{$$ = {"type":"double_arrow_point","stroke":"normal","text":$2};}
|
||||
| '--' text ARROW_CIRCLE
|
||||
{$$ = {"type":"arrow_circle","stroke":"normal","text":$2};}
|
||||
| 'START_DOUBLE_ARROW_CIRCLE' text ARROW_CIRCLE
|
||||
{$$ = {"type":"double_arrow_circle","stroke":"normal","text":$2};}
|
||||
| '--' text ARROW_CROSS
|
||||
{$$ = {"type":"arrow_cross","stroke":"normal","text":$2};}
|
||||
| 'START_DOUBLE_ARROW_CROSS' text ARROW_CROSS
|
||||
{$$ = {"type":"double_arrow_cross","stroke":"normal","text":$2};}
|
||||
| '--' text ARROW_OPEN
|
||||
{$$ = {"type":"arrow_open","stroke":"normal","text":$2};}
|
||||
| '-.' text DOTTED_ARROW_POINT
|
||||
{$$ = {"type":"arrow","stroke":"dotted","text":$2};}
|
||||
| 'START_DOUBLE_DOTTED_ARROW_POINT' text DOTTED_ARROW_POINT
|
||||
{$$ = {"type":"double_arrow_point","stroke":"dotted","text":$2};}
|
||||
| '-.' text DOTTED_ARROW_CIRCLE
|
||||
{$$ = {"type":"arrow_circle","stroke":"dotted","text":$2};}
|
||||
| 'START_DOUBLE_DOTTED_ARROW_CIRCLE' text DOTTED_ARROW_CIRCLE
|
||||
{$$ = {"type":"double_arrow_circle","stroke":"dotted","text":$2};}
|
||||
| '-.' text DOTTED_ARROW_CROSS
|
||||
{$$ = {"type":"arrow_cross","stroke":"dotted","text":$2};}
|
||||
| 'START_DOUBLE_DOTTED_ARROW_CROSS' text DOTTED_ARROW_CROSS
|
||||
{$$ = {"type":"double_arrow_cross","stroke":"dotted","text":$2};}
|
||||
| '-.' text DOTTED_ARROW_OPEN
|
||||
{$$ = {"type":"arrow_open","stroke":"dotted","text":$2};}
|
||||
| '==' text THICK_ARROW_POINT
|
||||
{$$ = {"type":"arrow","stroke":"thick","text":$2};}
|
||||
| 'START_DOUBLE_THICK_ARROW_POINT' text THICK_ARROW_POINT
|
||||
{$$ = {"type":"double_arrow_point","stroke":"thick","text":$2};}
|
||||
| '==' text THICK_ARROW_CIRCLE
|
||||
{$$ = {"type":"arrow_circle","stroke":"thick","text":$2};}
|
||||
| 'START_DOUBLE_THICK_ARROW_CIRCLE' text THICK_ARROW_CIRCLE
|
||||
{$$ = {"type":"double_arrow_circle","stroke":"thick","text":$2};}
|
||||
| '==' text THICK_ARROW_CROSS
|
||||
{$$ = {"type":"arrow_cross","stroke":"thick","text":$2};}
|
||||
| 'START_DOUBLE_THICK_ARROW_CROSS' text THICK_ARROW_CROSS
|
||||
{$$ = {"type":"double_arrow_cross","stroke":"thick","text":$2};}
|
||||
| '==' text THICK_ARROW_OPEN
|
||||
{$$ = {"type":"arrow_open","stroke":"thick","text":$2};}
|
||||
;
|
||||
|
||||
linkStatement: ARROW_POINT
|
||||
{$$ = {"type":"arrow","stroke":"normal"};}
|
||||
| DOUBLE_ARROW_POINT
|
||||
{$$ = {"type":"double_arrow_point","stroke":"normal"};}
|
||||
| ARROW_CIRCLE
|
||||
{$$ = {"type":"arrow_circle","stroke":"normal"};}
|
||||
| DOUBLE_ARROW_CIRCLE
|
||||
{$$ = {"type":"double_arrow_circle","stroke":"normal"};}
|
||||
| ARROW_CROSS
|
||||
{$$ = {"type":"arrow_cross","stroke":"normal"};}
|
||||
| DOUBLE_ARROW_CROSS
|
||||
{$$ = {"type":"double_arrow_cross","stroke":"normal"};}
|
||||
| ARROW_OPEN
|
||||
{$$ = {"type":"arrow_open","stroke":"normal"};}
|
||||
| DOTTED_ARROW_POINT
|
||||
{$$ = {"type":"arrow","stroke":"dotted"};}
|
||||
| DOUBLE_DOTTED_ARROW_POINT
|
||||
{$$ = {"type":"double_arrow_point","stroke":"dotted"};}
|
||||
| DOTTED_ARROW_CIRCLE
|
||||
{$$ = {"type":"arrow_circle","stroke":"dotted"};}
|
||||
| DOUBLE_DOTTED_ARROW_CIRCLE
|
||||
{$$ = {"type":"double_arrow_circle","stroke":"dotted"};}
|
||||
| DOTTED_ARROW_CROSS
|
||||
{$$ = {"type":"arrow_cross","stroke":"dotted"};}
|
||||
| DOUBLE_DOTTED_ARROW_CROSS
|
||||
{$$ = {"type":"double_arrow_cross","stroke":"dotted"};}
|
||||
| DOTTED_ARROW_OPEN
|
||||
{$$ = {"type":"arrow_open","stroke":"dotted"};}
|
||||
| THICK_ARROW_POINT
|
||||
{$$ = {"type":"arrow","stroke":"thick"};}
|
||||
| DOUBLE_THICK_ARROW_POINT
|
||||
{$$ = {"type":"double_arrow_point","stroke":"thick"};}
|
||||
| THICK_ARROW_CIRCLE
|
||||
{$$ = {"type":"arrow_circle","stroke":"thick"};}
|
||||
| DOUBLE_THICK_ARROW_CIRCLE
|
||||
{$$ = {"type":"double_arrow_circle","stroke":"thick"};}
|
||||
| THICK_ARROW_CROSS
|
||||
{$$ = {"type":"arrow_cross","stroke":"thick"};}
|
||||
| DOUBLE_THICK_ARROW_CROSS
|
||||
{$$ = {"type":"double_arrow_cross","stroke":"thick"};}
|
||||
| THICK_ARROW_OPEN
|
||||
{$$ = {"type":"arrow_open","stroke":"thick"};}
|
||||
;
|
||||
|
File diff suppressed because one or more lines are too long
@@ -592,6 +592,282 @@ describe('when parsing ', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('it should multi directional arrows', function () {
|
||||
describe('point', function () {
|
||||
it('should handle double edged nodes and edges', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA<-->B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_point')
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
it('should handle double edged nodes with text', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA<-- text -->B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_point')
|
||||
expect(edges[0].stroke).toBe('normal')
|
||||
expect(edges[0].text).toBe('text')
|
||||
})
|
||||
it('should handle double edged nodes and edges on thick arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA<==>B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_point')
|
||||
expect(edges[0].stroke).toBe('thick')
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
it('should handle double edged nodes with text on thick arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA<== text ==>B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_point')
|
||||
expect(edges[0].stroke).toBe('thick')
|
||||
expect(edges[0].text).toBe('text')
|
||||
})
|
||||
it('should handle double edged nodes and edges on dotted arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA<-.->B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_point')
|
||||
expect(edges[0].stroke).toBe('dotted')
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
it('should handle double edged nodes with text on dotted arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA<-. text .->B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_point')
|
||||
expect(edges[0].stroke).toBe('dotted')
|
||||
expect(edges[0].text).toBe('text')
|
||||
})
|
||||
})
|
||||
describe('cross', function () {
|
||||
it('should handle double edged nodes and edges', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA x--x B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_cross')
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
it('should handle double edged nodes with text', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA x-- text --x B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_cross')
|
||||
expect(edges[0].stroke).toBe('normal')
|
||||
expect(edges[0].text).toBe('text')
|
||||
})
|
||||
it('should handle double edged nodes and edges on thick arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA x==x B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_cross')
|
||||
expect(edges[0].stroke).toBe('thick')
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
it('should handle double edged nodes with text on thick arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA x== text ==x B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_cross')
|
||||
expect(edges[0].stroke).toBe('thick')
|
||||
expect(edges[0].text).toBe('text')
|
||||
})
|
||||
it('should handle double edged nodes and edges on dotted arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA x-.-x B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_cross')
|
||||
expect(edges[0].stroke).toBe('dotted')
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
it('should handle double edged nodes with text on dotted arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA x-. text .-x B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_cross')
|
||||
expect(edges[0].stroke).toBe('dotted')
|
||||
expect(edges[0].text).toBe('text')
|
||||
})
|
||||
})
|
||||
describe('circle', function () {
|
||||
it('should handle double edged nodes and edges', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA o--o B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_circle')
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
it('should handle double edged nodes with text', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA o-- text --o B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_circle')
|
||||
expect(edges[0].stroke).toBe('normal')
|
||||
expect(edges[0].text).toBe('text')
|
||||
})
|
||||
it('should handle double edged nodes and edges on thick arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA o==o B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_circle')
|
||||
expect(edges[0].stroke).toBe('thick')
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
it('should handle double edged nodes with text on thick arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA o== text ==o B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_circle')
|
||||
expect(edges[0].stroke).toBe('thick')
|
||||
expect(edges[0].text).toBe('text')
|
||||
})
|
||||
it('should handle double edged nodes and edges on dotted arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA o-.-o B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_circle')
|
||||
expect(edges[0].stroke).toBe('dotted')
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
it('should handle double edged nodes with text on dotted arrows', function () {
|
||||
const res = flow.parser.parse('graph TD;\nA o-. text .-o B;')
|
||||
|
||||
const vert = flow.parser.yy.getVertices()
|
||||
const edges = flow.parser.yy.getEdges()
|
||||
|
||||
expect(vert['A'].id).toBe('A')
|
||||
expect(vert['B'].id).toBe('B')
|
||||
expect(edges.length).toBe(1)
|
||||
expect(edges[0].start).toBe('A')
|
||||
expect(edges[0].end).toBe('B')
|
||||
expect(edges[0].type).toBe('double_arrow_circle')
|
||||
expect(edges[0].stroke).toBe('dotted')
|
||||
expect(edges[0].text).toBe('text')
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
describe('it should handle text on edges', function () {
|
||||
it('it should handle text without space', function () {
|
||||
const res = flow.parser.parse('graph TD;A--x|textNoSpace|B;')
|
||||
|
Reference in New Issue
Block a user