1- import { Mermaid2svgService } from './mermaid2svg ' ;
1+ import { Flow2svgService } from './flow2svg ' ;
22import { getFactoryDimensions , SvgResult } from '../public_api' ;
33
4- const input = `Start(" My start" ):::normal
5- N1(" Node 1" ):::normal
6- N2(" Node 2" ):::normal
7- N3(" Node 3" ):::errorOutline
8- End(" End node" ):::normal
9- Start --> |success| N1
10- Start --> |success| N2
11- Start --> |success| N3
12- N1 --> |failure| End
13- N2 --> |success| End
14- N1 --> |success| N2
15- N3 --> |success| End` ;
4+ const input = `Start('<text> My start</text>' ):::normal
5+ N1('<text> Node 1</text>' ):::normal
6+ N2('<text> Node 2</text>' ):::normal
7+ N3('<text> Node 3</text>' ):::errorOutline
8+ End('<text> End node</text>' ):::normal
9+ Start --> |<text> success</text> | N1
10+ Start --> |<text> success</text> | N2
11+ Start --> |<text> success</text> | N3
12+ N1 --> |<text> failure</text> | End
13+ N2 --> |<text> success</text> | End
14+ N1 --> |<text> success</text> | N2
15+ N3 --> |<text> success</text> | End` ;
1616
17- // In the GUI, enter the above Mermaid text. Then look at the bottom
17+ // In the GUI, enter the above Flow text. Then look at the bottom
1818// under the heading "Static SVG". If that image looks good, copy
1919// the text next to the static SVG here.
2020//
@@ -24,7 +24,7 @@ N3 --> |success| End`;
2424//
2525const expectedSvg = `<svg class="svg" xmlns="http://www.w3.org/2000/svg"
2626 width="286" height="480" >
27- <defs>
27+ <defs>
2828 <style>
2929 .rectangle {
3030 fill: transparent;
@@ -73,90 +73,90 @@ const expectedSvg = `<svg class="svg" xmlns="http://www.w3.org/2000/svg"
7373 <path d="M 0 0 L 4 2 L 0 4 z" />
7474 </marker>
7575 </defs>
76- <g class="frank-flowchart-node-Start" transform="translate(78, 3)">
76+ <g class="frank-flowchart-node-Start" transform="translate(78, 3)">
7777 <rect class="rectangle"
7878 width="95"
7979 height="54"
8080 rx="5">
8181 </rect>
8282 </g>
83- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=# text x="125" y="30">My start</text></g>
84- <g class="frank-flowchart-node-N1" transform="translate(87, 123)">
83+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="125" y="30">My start</text></g>
84+ <g class="frank-flowchart-node-N1" transform="translate(87, 123)">
8585 <rect class="rectangle"
8686 width="77"
8787 height="54"
8888 rx="5">
8989 </rect>
9090 </g>
91- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=# text x="125" y="150">Node 1</text></g>
92- <g class="frank-flowchart-node-N3" transform="translate(194, 123)">
91+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="125" y="150">Node 1</text></g>
92+ <g class="frank-flowchart-node-N3" transform="translate(194, 123)">
9393 <rect class="rectangle errorOutline"
9494 width="77"
9595 height="54"
9696 rx="5">
9797 </rect>
9898 </g>
99- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=# text x="232" y="150">Node 3</text></g>
100- <g class="frank-flowchart-node-N2" transform="translate(15, 243)">
99+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="232" y="150">Node 3</text></g>
100+ <g class="frank-flowchart-node-N2" transform="translate(15, 243)">
101101 <rect class="rectangle"
102102 width="77"
103103 height="54"
104104 rx="5">
105105 </rect>
106106 </g>
107- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=# text x="53" y="270">Node 2</text></g>
108- <g class="frank-flowchart-node-End" transform="translate(90, 363)">
107+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="53" y="270">Node 2</text></g>
108+ <g class="frank-flowchart-node-End" transform="translate(90, 363)">
109109 <rect class="rectangle"
110110 width="95"
111111 height="54"
112112 rx="5">
113113 </rect>
114114 </g>
115- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=# text x="137" y="390">End node</text></g>
116- <g class="frank-flowchart-edge-Start-N1">
115+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="137" y="390">End node</text></g>
116+ <g class="frank-flowchart-edge-Start-N1">
117117 <polyline class="line" points="125,56 125,123" marker-end="url(#arrow)"/>
118118 </g>
119- <g class="frank-flowchart-edge-Start-intermediate1">
119+ <g class="frank-flowchart-edge-Start-intermediate1">
120120 <polyline class="line" points="101,56 42,150" />
121121 </g>
122- <g class="frank-flowchart-edge-intermediate1-N2">
122+ <g class="frank-flowchart-edge-intermediate1-N2">
123123 <polyline class="line" points="42,150 34,243" marker-end="url(#arrow)"/>
124124 </g>
125- <g class="frank-flowchart-edge-Start-N3">
125+ <g class="frank-flowchart-edge-Start-N3">
126126 <polyline class="line" points="148,56 232,123" marker-end="url(#arrow)"/>
127127 </g>
128- <g class="frank-flowchart-edge-N1-intermediate2">
128+ <g class="frank-flowchart-edge-N1-intermediate2">
129129 <polyline class="line error" points="144,176 140,270" />
130130 </g>
131- <g class="frank-flowchart-edge-intermediate2-End">
131+ <g class="frank-flowchart-edge-intermediate2-End">
132132 <polyline class="line error" points="140,270 137,363" marker-end="url(#arrow)"/>
133133 </g>
134- <g class="frank-flowchart-edge-N2-End">
134+ <g class="frank-flowchart-edge-N2-End">
135135 <polyline class="line" points="53,296 113,363" marker-end="url(#arrow)"/>
136136 </g>
137- <g class="frank-flowchart-edge-N1-N2">
137+ <g class="frank-flowchart-edge-N1-N2">
138138 <polyline class="line" points="106,176 72,243" marker-end="url(#arrow)"/>
139139 </g>
140- <g class="frank-flowchart-edge-N3-intermediate3">
140+ <g class="frank-flowchart-edge-N3-intermediate3">
141141 <polyline class="line error" points="232,176 196,270" />
142142 </g>
143- <g class="frank-flowchart-edge-intermediate3-End">
143+ <g class="frank-flowchart-edge-intermediate3-End">
144144 <polyline class="line error" points="196,270 160,363" marker-end="url(#arrow)"/>
145145 </g>
146- <g text-anchor="middle" dominant-baseline="middle"><text class="label-text" x="82" y="86" font-size="10">success</text><text class="label-text" x="125" y="86" font-size="10">success</text><text class="label-text" x="186" y="86" font-size="10">success</text><text class="label-text" x="91" y="206" font-size="10">success</text><text class="label-text" x="143" y="206" font-size="10">failure</text><text class="label-text" x="221" y="206" font-size="10">success</text><text class="label-text" x="80" y="326" font-size="10">success</text></g></svg>`;
146+ <g text-anchor="middle" dominant-baseline="middle"><text class="label-text" x="82" y="86" font-size="10">success</text><text class="label-text" x="125" y="86" font-size="10">success</text><text class="label-text" x="186" y="86" font-size="10">success</text><text class="label-text" x="91" y="206" font-size="10">success</text><text class="label-text" x="143" y="206" font-size="10">failure</text><text class="label-text" x="221" y="206" font-size="10">success</text><text class="label-text" x="80" y="326" font-size="10">success</text></g></svg>` ;
147147
148- const inputMultiline = `Start(" My start<br/> subtitle" ):::normal
149- N1(" Node 1<br/> subtitle" ):::normal
150- N2(" Node 2<br/> subtitle" ):::normal
151- N3(" Node 3<br/> subtitle" ):::errorOutline
152- End(" End node<br/> subtitle" ):::normal
153- Start --> |success<br/> other| N1
154- Start --> |success<br/> other| N2
155- Start --> |success| N3
156- N1 --> |failure| End
157- N2 --> |success| End
158- N1 --> |success| N2
159- N3 --> |success| End` ;
148+ const inputMultiline = `Start('<text> My start</text><text> subtitle</text>' ):::normal
149+ N1('<text> Node 1</text><text> subtitle</text>' ):::normal
150+ N2('<text> Node 2</text><text> subtitle</text>' ):::normal
151+ N3('<text> Node 3</text><text> subtitle</text>' ):::errorOutline
152+ End('<text> End node</text><text> subtitle</text>' ):::normal
153+ Start --> |<text> success</text><text> other</text> | N1
154+ Start --> |<text> success</text><text> other</text> | N2
155+ Start --> |<text> success</text> | N3
156+ N1 --> |<text> failure</text> | End
157+ N2 --> |<text> success</text> | End
158+ N1 --> |<text> success</text> | N2
159+ N3 --> |<text> success</text> | End` ;
160160
161161const expectedMultiline = `<svg class="svg" xmlns="http://www.w3.org/2000/svg"
162162 width="326" height="480" >
@@ -216,39 +216,39 @@ const expectedMultiline = `<svg class="svg" xmlns="http://www.w3.org/2000/svg"
216216 rx="5">
217217 </rect>
218218 </g>
219- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=#text x="138" y="23">My start</text><text data-html-node=# text x="138" y="39">subtitle</text></g>
219+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="138" y="23">My start</text><text x="138" y="39">subtitle</text></g>
220220 <g class="frank-flowchart-node-N1" transform="translate(91, 123)">
221221 <rect class="rectangle"
222222 width="95"
223223 height="54"
224224 rx="5">
225225 </rect>
226226 </g>
227- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=#text x="138" y="143">Node 1</text><text data-html-node=# text x="138" y="159">subtitle</text></g>
227+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="138" y="143">Node 1</text><text x="138" y="159">subtitle</text></g>
228228 <g class="frank-flowchart-node-N3" transform="translate(216, 123)">
229229 <rect class="rectangle errorOutline"
230230 width="95"
231231 height="54"
232232 rx="5">
233233 </rect>
234234 </g>
235- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=#text x="263" y="143">Node 3</text><text data-html-node=# text x="263" y="159">subtitle</text></g>
235+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="263" y="143">Node 3</text><text x="263" y="159">subtitle</text></g>
236236 <g class="frank-flowchart-node-N2" transform="translate(15, 243)">
237237 <rect class="rectangle"
238238 width="95"
239239 height="54"
240240 rx="5">
241241 </rect>
242242 </g>
243- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=#text x="62" y="263">Node 2</text><text data-html-node=# text x="62" y="279">subtitle</text></g>
243+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="62" y="263">Node 2</text><text x="62" y="279">subtitle</text></g>
244244 <g class="frank-flowchart-node-End" transform="translate(108, 363)">
245245 <rect class="rectangle"
246246 width="95"
247247 height="54"
248248 rx="5">
249249 </rect>
250250 </g>
251- <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text data-html-node=#text x="155" y="383">End node</text><text data-html-node=# text x="155" y="399">subtitle</text></g>
251+ <g class="rect-text" text-anchor="middle" dominant-baseline="middle"><text x="155" y="383">End node</text><text x="155" y="399">subtitle</text></g>
252252 <g class="frank-flowchart-edge-Start-N1">
253253 <polyline class="line" points="138,56 138,123" marker-end="url(#arrow)"/>
254254 </g>
@@ -281,30 +281,32 @@ const expectedMultiline = `<svg class="svg" xmlns="http://www.w3.org/2000/svg"
281281 </g>
282282 <g text-anchor="middle" dominant-baseline="middle"><text class="label-text" x="92" y="78" font-size="10">success</text><text class="label-text" x="92" y="94" font-size="10">other</text><text class="label-text" x="138" y="78" font-size="10">success</text><text class="label-text" x="138" y="94" font-size="10">other</text><text class="label-text" x="207" y="86" font-size="10">success</text><text class="label-text" x="101" y="206" font-size="10">success</text><text class="label-text" x="160" y="206" font-size="10">failure</text><text class="label-text" x="249" y="206" font-size="10">success</text><text class="label-text" x="93" y="326" font-size="10">success</text></g></svg>` ;
283283
284- describe ( 'Mermaid2svg - please maintain this test using the GUI' , ( ) => {
285- let service : Mermaid2svgService ;
284+ describe ( 'Flow2svg - please maintain this test using the GUI' , ( ) => {
285+ let service : Flow2svgService ;
286286
287287 beforeEach ( ( ) => {
288288 // No need to test injection - if injection does not work then the app does not show
289- service = new Mermaid2svgService ( getFactoryDimensions ( ) ) ;
289+ service = new Flow2svgService ( getFactoryDimensions ( ) ) ;
290290 } ) ;
291291
292292 it ( 'Test the plain SVG' , ( done ) => {
293- service . mermaid2svg ( input ) . then ( ( svg ) => {
294- expect ( svg . split ( '\n' ) ) . toEqual ( expectedSvg ! . split ( '\n' ) ) ;
293+ service . flow2svg ( input ) . then ( ( svg ) => {
294+ expect ( svg . split ( '\n' ) . map ( ( line ) => line . trim ( ) ) ) . toEqual ( expectedSvg ! . split ( '\n' ) . map ( ( line ) => line . trim ( ) ) ) ;
295295 done ( ) ;
296296 } ) ;
297297 } ) ;
298298
299299 it ( 'Test SVG with multiline nodes and edges' , ( done ) => {
300- service . mermaid2svg ( inputMultiline ) . then ( ( svg ) => {
301- expect ( svg . split ( '\n' ) ) . toEqual ( expectedMultiline ! . split ( '\n' ) ) ;
300+ service . flow2svg ( inputMultiline ) . then ( ( svg ) => {
301+ expect ( svg . split ( '\n' ) . map ( ( line ) => line . trim ( ) ) ) . toEqual (
302+ expectedMultiline ! . split ( '\n' ) . map ( ( line ) => line . trim ( ) ) ,
303+ ) ;
302304 done ( ) ;
303305 } ) ;
304306 } ) ;
305307
306308 it ( 'Test with statistics' , ( done ) => {
307- service . mermaid2svgStatistics ( input ) . then ( ( statistics ) => {
309+ service . flow2svgStatistics ( input ) . then ( ( statistics ) => {
308310 expect ( statistics . svg ) . toEqual ( expectedSvg ) ;
309311 expect ( statistics . numNodes ) . toEqual ( 5 ) ;
310312 expect ( statistics . numEdges ) . toEqual ( 7 ) ;
@@ -314,8 +316,8 @@ describe('Mermaid2svg - please maintain this test using the GUI', () => {
314316 } ) ;
315317
316318 it ( 'Test that real calculation is done only once' , ( done ) => {
317- const first : Promise < SvgResult > = service . mermaid2svgStatistics ( input ) ;
318- const second : Promise < string > = service . mermaid2svg ( input ) ;
319+ const first : Promise < SvgResult > = service . flow2svgStatistics ( input ) ;
320+ const second : Promise < string > = service . flow2svg ( input ) ;
319321 Promise . all ( [ first , second ] ) . then ( ( ) => {
320322 expect ( service . numSvgCalculations ) . toEqual ( 1 ) ;
321323 expect ( service . getHashes ( ) ) . toHaveSize ( 1 ) ;
0 commit comments