Skip to content

Commit

Permalink
fix: Display no arrows for open links
Browse files Browse the repository at this point in the history
  • Loading branch information
jahredhope committed Nov 28, 2024
1 parent 64554a6 commit b357624
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-tigers-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mermaid': patch
---

Display no arrows for open links
33 changes: 33 additions & 0 deletions packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,36 @@ describe('flow db addClass', () => {
expect(classes.get('a')?.styles).toEqual(['stroke-width: 8px']);
});
});

describe('flow db getData', () => {
beforeEach(() => {
flowDb.clear();
});
it('should end in point for for single directional arrows', () => {
flowDb.addLink(['A'], ['B'], { type: 'arrow_point' });

const { edges } = flowDb.getData();

expect(edges.length).toBe(1);
expect(edges[0].arrowTypeStart).toBe('none');
expect(edges[0].arrowTypeEnd).toBe('arrow_point');
});
it('should start and end in points for multi directional arrows', () => {
flowDb.addLink(['A'], ['B'], { type: 'double_arrow_point' });

const { edges } = flowDb.getData();

expect(edges.length).toBe(1);
expect(edges[0].arrowTypeStart).toBe('arrow_point');
expect(edges[0].arrowTypeEnd).toBe('arrow_point');
});
it('should have no points for open arrows', () => {
flowDb.addLink(['A'], ['B'], { type: 'arrow_open' });

const { edges } = flowDb.getData();

expect(edges.length).toBe(1);
expect(edges[0].arrowTypeStart).toBe('none');
expect(edges[0].arrowTypeEnd).toBe('none');
});
});
3 changes: 3 additions & 0 deletions packages/mermaid/src/diagrams/flowchart/flowDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@ const destructEdgeType = (type: string | undefined) => {
arrowTypeStart = type.replace('double_', '');
arrowTypeEnd = arrowTypeStart;
break;
case 'arrow_open':
arrowTypeEnd = 'none';
break;
}
return { arrowTypeStart, arrowTypeEnd };
};
Expand Down

0 comments on commit b357624

Please sign in to comment.