Skip to content

Commit babeaa0

Browse files
committed
added changeset and unit test
1 parent 677a97c commit babeaa0

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.changeset/quiet-tires-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'mermaid': major
3+
---
4+
5+
ensure quadrant titles wrap and stay within bounds

packages/mermaid/src/diagrams/quadrant-chart/quadrantDb.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import quadrantDb from './quadrantDb.js';
2+
// @ts-ignore: JISON doesn't support types
3+
import parser from './parser/quadrant.jison';
24

35
describe('quadrant unit tests', () => {
46
it('should parse the styles array and return a StylesObject', () => {
@@ -47,4 +49,28 @@ describe('quadrant unit tests', () => {
4749
'value for stroke-width 30 is invalid, please use a valid number of pixels (eg. 10px)'
4850
);
4951
});
52+
it('should store long quadrant titles correctly (wrap handled in renderer)', () => {
53+
const input = `
54+
quadrantChart
55+
quadrant-1 "🔥 This is a very long quadrant title that should wrap properly inside the box"
56+
quadrant-2 "💡 Another long label that should be parsed fully"
57+
quadrant-3 "Short"
58+
quadrant-4 "🚀 Final test case with long label"
59+
`;
60+
61+
quadrantDb.clear();
62+
parser.yy = quadrantDb;
63+
parser.quadrantDb(input);
64+
65+
expect(quadrantDb.getQuadrantData().quadrants[0].text.text).toBe(
66+
'🔥 This is a very long quadrant title that should wrap properly inside the box'
67+
);
68+
expect(quadrantDb.getQuadrantData().quadrants[1].text.text).toBe(
69+
'💡 Another long label that should be parsed fully'
70+
);
71+
expect(quadrantDb.getQuadrantData().quadrants[2].text.text).toBe('Short');
72+
expect(quadrantDb.getQuadrantData().quadrants[3].text.text).toBe(
73+
'🚀 Final test case with long label'
74+
);
75+
});
5076
});

0 commit comments

Comments
 (0)