mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 14:29:25 +02:00
Added support for Diagram title
This commit is contained in:
@@ -154,6 +154,7 @@ statement
|
||||
:
|
||||
| SPACE statement
|
||||
| directive
|
||||
| title title_value { $$=$2.trim();yy.setDiagramTitle($$); }
|
||||
| X_AXIS parseXAxis
|
||||
| Y_AXIS parseYAxis
|
||||
| parseLine
|
||||
|
@@ -11,6 +11,7 @@ const parserFnConstructor = (str: string) => {
|
||||
const mockDB: Record<string, Mock<any, any>> = {
|
||||
parseDirective: vi.fn(),
|
||||
setOrientation: vi.fn(),
|
||||
setDiagramTitle: vi.fn(),
|
||||
setXAxisTitle: vi.fn(),
|
||||
setXAxisRangeData: vi.fn(),
|
||||
addXAxisBand: vi.fn(),
|
||||
@@ -43,6 +44,12 @@ describe('Testing xychart jison file', () => {
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
});
|
||||
|
||||
it('parse title of the chart', () => {
|
||||
const str = 'xychart-beta \n title This is a title';
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
expect(mockDB.setDiagramTitle).toHaveBeenCalledWith('This is a title');
|
||||
});
|
||||
|
||||
it('should be able to parse directive', () => {
|
||||
const str =
|
||||
'%%{init: {"xychart": {"chartWidth": 600, "chartHeight": 600} } }%% \n xychart-beta';
|
||||
|
Reference in New Issue
Block a user