diff --git a/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts b/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts index 10fc869638d..68ef0c01857 100644 --- a/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts +++ b/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts @@ -46,5 +46,46 @@ describe('Sankey diagram', function () { `) ); }); + + const issue7528PerformanceDiagram = ` + Agricultural 'waste',Bio-conversion,124.729 + Bio-conversion,Liquid,0.597 + Bio-conversion,Losses,26.862 + Bio-conversion,Solid,280.322 + Bio-conversion,Gas,81.144 + Biofuel imports,Liquid,35 + Biomass imports,Solid,35 + Coal imports,Coal,11.606 + Coal reserves,Coal,63.965 + Coal,Solid,75.571 + District heating,Industry,10.639 + District heating,Heating and cooling - homes,22.505 + District heating,Heating and cooling - commercial,46.184 + Electricity grid,Over generation / exports,104.453 + Electricity grid,Lighting & appliances - commercial,113.726 + Electricity grid,Lighting & appliances - homes,27.14 + `; + + const issue7528SpecialCharacterNodes = [ + "Agricultural 'waste'", + 'Heating and cooling - homes', + 'Heating and cooling - commercial', + 'Over generation / exports', + 'Lighting & appliances - commercial', + 'Lighting & appliances - homes', + ]; + + for (const syntax of ['sankey-beta', 'sankey'] as const) { + it(`parses the issue #7528 sample with ${syntax} syntax`, function () { + sankey.parser.parse(prepareTextForParsing(`${syntax}${issue7528PerformanceDiagram}`)); + + const graph = sankey.parser.yy.getGraph(); + expect(graph.nodes).toHaveLength(19); + expect(graph.links).toHaveLength(16); + expect(graph.nodes).toEqual( + expect.arrayContaining(issue7528SpecialCharacterNodes.map((id) => ({ id }))) + ); + }); + } }); });