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