mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 21:39:40 +02:00
WIP - fixing grammar added CircleNode
This commit is contained in:
@@ -6,30 +6,38 @@ grammar Mindmap
|
|||||||
|
|
||||||
entry MindmapDoc:
|
entry MindmapDoc:
|
||||||
MINDMAP_KEYWORD (newline=NL)?
|
MINDMAP_KEYWORD (newline=NL)?
|
||||||
(statements+=Statement)*;
|
(MindmapRows+=MindmapRow)*;
|
||||||
|
|
||||||
Statement:
|
MindmapRow:
|
||||||
(indent=INDENTATION)? element=Element (terminator=NL)?;
|
(indent=INDENTATION)? item=Item (terminator=NL)?;
|
||||||
|
|
||||||
Element:
|
Item:
|
||||||
Node | IconDecoration | ClassDecoration;
|
Node | IconDecoration | ClassDecoration;
|
||||||
|
|
||||||
|
// Use a special rule order to handle the parsing precedence
|
||||||
Node:
|
Node:
|
||||||
ComplexNode | SimpleNode;
|
CircleNode | OtherComplex | SimpleNode;
|
||||||
|
|
||||||
SimpleNode:
|
// Specifically handle double parentheses case - highest priority
|
||||||
|
CircleNode:
|
||||||
|
id=ID '((' desc=(ID | STRING) '))';
|
||||||
|
|
||||||
|
// Handle other complex node variants
|
||||||
|
OtherComplex:
|
||||||
id=ID
|
id=ID
|
||||||
// Ensure it does not match the structure of a ComplexNode
|
(
|
||||||
(NL | INDENTATION)?;
|
('[' '[' desc=(ID | STRING) ']' ']') |
|
||||||
|
('{' '{' desc=(ID | STRING) '}' '}') |
|
||||||
|
('(-' desc=(ID | STRING) '-)') |
|
||||||
|
('(' desc=(ID | STRING) ')')
|
||||||
|
);
|
||||||
|
|
||||||
ComplexNode:
|
// Simple node as fallback
|
||||||
(id=ID)?
|
SimpleNode:
|
||||||
start=(LPAREN|LBRACKET|LCURLY|START_CLOUD|DOUBLE_PAREN)
|
id=ID;
|
||||||
desc=(ID|STRING)
|
|
||||||
end=(RPAREN|RBRACKET|RCURLY|END_CLOUD|DOUBLE_PAREN);
|
|
||||||
|
|
||||||
IconDecoration:
|
IconDecoration:
|
||||||
ICON_KEYWORD content=(ID|STRING) RPAREN;
|
ICON_KEYWORD content=(ID|STRING) ')';
|
||||||
|
|
||||||
ClassDecoration:
|
ClassDecoration:
|
||||||
CLASS_KEYWORD content=(ID|STRING);
|
CLASS_KEYWORD content=(ID|STRING);
|
||||||
@@ -39,17 +47,6 @@ terminal MINDMAP_KEYWORD: 'mindmap';
|
|||||||
terminal ICON_KEYWORD: '::icon(';
|
terminal ICON_KEYWORD: '::icon(';
|
||||||
terminal CLASS_KEYWORD: ':::';
|
terminal CLASS_KEYWORD: ':::';
|
||||||
|
|
||||||
// Delimiters - using unique string literals
|
|
||||||
terminal LPAREN: '(';
|
|
||||||
terminal RPAREN: ')';
|
|
||||||
terminal DOUBLE_PAREN: '((' | '))'; // Combined to avoid regex conflicts
|
|
||||||
terminal LBRACKET: '[';
|
|
||||||
terminal RBRACKET: ']';
|
|
||||||
terminal LCURLY: '{{';
|
|
||||||
terminal RCURLY: '}}';
|
|
||||||
terminal START_CLOUD: '(-';
|
|
||||||
terminal END_CLOUD: '-)';
|
|
||||||
|
|
||||||
// Basic token types
|
// Basic token types
|
||||||
terminal ID: /[a-zA-Z0-9_\-\.\/]+/;
|
terminal ID: /[a-zA-Z0-9_\-\.\/]+/;
|
||||||
terminal STRING: /"[^"]*"|'[^']*'/;
|
terminal STRING: /"[^"]*"|'[^']*'/;
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { mindmapParse as parse } from './test-util.js';
|
import { mindmapParse as parse } from './test-util.js';
|
||||||
import { keys } from '../../mermaid-flowchart-elk/dist/packages/mermaid/src/diagrams/state/id-cache';
|
import type { CircleNode } from '../src/language/generated/ast';
|
||||||
|
import { MindmapRow, Item } from '../src/language/generated/ast';
|
||||||
|
|
||||||
// Tests for mindmap parser with simple root and child nodes
|
// Tests for mindmap parser with simple root and child nodes
|
||||||
describe('MindMap Parser Tests', () => {
|
describe('MindMap Parser Tests', () => {
|
||||||
@@ -22,11 +23,11 @@ describe('MindMap Parser Tests', () => {
|
|||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
|
|
||||||
// Check if we have a statement
|
// Check if we have a statement
|
||||||
expect(result.value.statements).toBeDefined();
|
expect(result.value.rows).toBeDefined();
|
||||||
expect(result.value.statements.length).toBeGreaterThan(0);
|
expect(result.value.rows.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
// Check the content of the root node
|
// Check the content of the root node
|
||||||
const rootNode = result.value.statements[0];
|
const rootNode = result.value.rows[0];
|
||||||
expect(rootNode).toBeDefined();
|
expect(rootNode).toBeDefined();
|
||||||
expect(rootNode.content).toBe('root');
|
expect(rootNode.content).toBe('root');
|
||||||
});
|
});
|
||||||
@@ -37,54 +38,49 @@ describe('MindMap Parser Tests', () => {
|
|||||||
'mindmap\nroot((Root))\n child1((Child 1))\n child2((Child 2))\n grandchild((Grand Child))'
|
'mindmap\nroot((Root))\n child1((Child 1))\n child2((Child 2))\n grandchild((Grand Child))'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Debug information - commented out to avoid linter errors
|
const rows = result.value.MindmapRows;
|
||||||
// Result successful: result.successful
|
const r0 = rows[0];
|
||||||
// Statements length: result.value?.statements?.length
|
const r1 = rows[1];
|
||||||
// If statements exist, they would have properties like id, type, text, depth
|
|
||||||
|
|
||||||
const statements = result.value.statements;
|
expect(r0.$type).toBe('MindmapRow');
|
||||||
const s0 = statements[0];
|
const node0 = r0.item as CircleNode;
|
||||||
const s1 = statements[1];
|
expect(node0.$type).toBe('CircleNode');
|
||||||
|
expect(node0.desc).toBe('Root');
|
||||||
|
expect(node0.id).toBe('root');
|
||||||
|
|
||||||
console.debug('Statements:', s0);
|
expect(r1.$type).toBe('MindmapRow');
|
||||||
|
const node1 = r1.item as CircleNode;
|
||||||
expect(result.value.statements[0].$type).toBe('Statement');
|
console.debug('NODE1:', node1);
|
||||||
// expect(result.value.statements[0].element.$type).toBe('ComplexNode');
|
expect(node1.$type).toBe('CircleNode');
|
||||||
expect(s0.element.$type).toBe('ComplexNode');
|
expect(result.value.rows[1].element.ID).toBe('Root');
|
||||||
expect(Object.keys(s0)).toBe('Root');
|
expect(result.value.rows[1].element.desc).toBe('Root');
|
||||||
expect(s0.element.ID).toBe('Root');
|
expect(Object.keys(result.value.rows[1].element)).toBe('root');
|
||||||
|
expect(result.value.rows[1].indent).toBe('indent');
|
||||||
expect(result.value.statements[1].$type).toBe('Statement');
|
expect(Object.keys(result.value.rows[1].element)).toBe(true);
|
||||||
expect(result.value.statements[1].element.$type).toBe('ComplexNode');
|
expect(result.value.rows[1].element.id).toBe('SimpleNode');
|
||||||
expect(result.value.statements[1].element.ID).toBe('Root');
|
|
||||||
expect(result.value.statements[1].element.desc).toBe('Root');
|
|
||||||
expect(Object.keys(result.value.statements[1].element)).toBe('root');
|
|
||||||
expect(result.value.statements[1].indent).toBe('indent');
|
|
||||||
expect(Object.keys(result.value.statements[1].element)).toBe(true);
|
|
||||||
expect(result.value.statements[1].element.id).toBe('SimpleNode');
|
|
||||||
|
|
||||||
// Temporarily commenting out failing assertions
|
// Temporarily commenting out failing assertions
|
||||||
// expect(result.successful).toBe(true);
|
// expect(result.successful).toBe(true);
|
||||||
// Check that there are 4 statements: mindmap, root, child1, child2, grandchild
|
// Check that there are 4 rows: mindmap, root, child1, child2, grandchild
|
||||||
expect(result.value.statements.length).toBe(5);
|
expect(result.value.rows.length).toBe(5);
|
||||||
// Check that the first statement is the mindmap
|
// Check that the first statement is the mindmap
|
||||||
expect(result.value.statements[0].type).toBe('mindmap');
|
expect(result.value.rows[0].type).toBe('mindmap');
|
||||||
// Check that the second statement is the root
|
// Check that the second statement is the root
|
||||||
expect(result.value.statements[1].type.type).toBe('circle');
|
expect(result.value.rows[1].type.type).toBe('circle');
|
||||||
expect(result.value.statements[1].text).toBe('Root');
|
expect(result.value.rows[1].text).toBe('Root');
|
||||||
expect(result.value.statements[1].depth).toBe(0);
|
expect(result.value.rows[1].depth).toBe(0);
|
||||||
// Check that the third statement is the first child
|
// Check that the third statement is the first child
|
||||||
expect(result.value.statements[2].type.type).toBe('circle');
|
expect(result.value.rows[2].type.type).toBe('circle');
|
||||||
expect(result.value.statements[2].text).toBe('Child 1');
|
expect(result.value.rows[2].text).toBe('Child 1');
|
||||||
expect(result.value.statements[2].depth).toBe(1);
|
expect(result.value.rows[2].depth).toBe(1);
|
||||||
// Check that the fourth statement is the second child
|
// Check that the fourth statement is the second child
|
||||||
expect(result.value.statements[3].type.type).toBe('circle');
|
expect(result.value.rows[3].type.type).toBe('circle');
|
||||||
expect(result.value.statements[3].text).toBe('Child 2');
|
expect(result.value.rows[3].text).toBe('Child 2');
|
||||||
expect(result.value.statements[3].depth).toBe(1);
|
expect(result.value.rows[3].depth).toBe(1);
|
||||||
// Check that the fifth statement is the grandchild
|
// Check that the fifth statement is the grandchild
|
||||||
expect(result.value.statements[4].type.type).toBe('circle');
|
expect(result.value.rows[4].type.type).toBe('circle');
|
||||||
expect(result.value.statements[4].text).toBe('Grand Child');
|
expect(result.value.rows[4].text).toBe('Grand Child');
|
||||||
expect(result.value.statements[4].depth).toBe(2);
|
expect(result.value.rows[4].depth).toBe(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -93,17 +89,17 @@ describe('Hierarchy (ported from mindmap.spec.ts)', () => {
|
|||||||
const result = parse('mindmap\nroot');
|
const result = parse('mindmap\nroot');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('root');
|
expect(result.value.rows[0].content).toBe('root');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('MMP-2 should handle a hierarchical mindmap definition', () => {
|
it('MMP-2 should handle a hierarchical mindmap definition', () => {
|
||||||
const result = parse('mindmap\nroot\n child1\n child2');
|
const result = parse('mindmap\nroot\n child1\n child2');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
// Langium AST may not have children as nested objects, so just check statements
|
// Langium AST may not have children as nested objects, so just check rows
|
||||||
expect(result.value.statements[0].content).toBe('root');
|
expect(result.value.rows[0].content).toBe('root');
|
||||||
expect(result.value.statements[1].content).toBe('child1');
|
expect(result.value.rows[1].content).toBe('child1');
|
||||||
expect(result.value.statements[2].content).toBe('child2');
|
expect(result.value.rows[2].content).toBe('child2');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('MMP-3 should handle a simple root definition with a shape and without an id', () => {
|
it('MMP-3 should handle a simple root definition with a shape and without an id', () => {
|
||||||
@@ -111,17 +107,17 @@ describe('Hierarchy (ported from mindmap.spec.ts)', () => {
|
|||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
// The content should be 'root', shape info may not be present in AST
|
// The content should be 'root', shape info may not be present in AST
|
||||||
expect(result.value.statements[0].content).toBe('root');
|
expect(result.value.rows[0].content).toBe('root');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('MMP-4 should handle a deeper hierarchical mindmap definition', () => {
|
it('MMP-4 should handle a deeper hierarchical mindmap definition', () => {
|
||||||
const result = parse('mindmap\nroot\n child1\n leaf1\n child2');
|
const result = parse('mindmap\nroot\n child1\n leaf1\n child2');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('root');
|
expect(result.value.rows[0].content).toBe('root');
|
||||||
expect(result.value.statements[1].content).toBe('child1');
|
expect(result.value.rows[1].content).toBe('child1');
|
||||||
expect(result.value.statements[2].content).toBe('leaf1');
|
expect(result.value.rows[2].content).toBe('leaf1');
|
||||||
expect(result.value.statements[3].content).toBe('child2');
|
expect(result.value.rows[3].content).toBe('child2');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('MMP-5 Multiple roots are illegal', () => {
|
it('MMP-5 Multiple roots are illegal', () => {
|
||||||
@@ -144,7 +140,7 @@ describe('Nodes (ported from mindmap.spec.ts)', () => {
|
|||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
// Langium AST: check content, id, and maybe type if available
|
// Langium AST: check content, id, and maybe type if available
|
||||||
expect(result.value.statements[0].content).toBe('The root');
|
expect(result.value.rows[0].content).toBe('The root');
|
||||||
// TODO: check id and type if present in AST
|
// TODO: check id and type if present in AST
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -152,8 +148,8 @@ describe('Nodes (ported from mindmap.spec.ts)', () => {
|
|||||||
const result = parse('mindmap\nroot\n theId(child1)');
|
const result = parse('mindmap\nroot\n theId(child1)');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('root');
|
expect(result.value.rows[0].content).toBe('root');
|
||||||
expect(result.value.statements[1].content).toBe('child1');
|
expect(result.value.rows[1].content).toBe('child1');
|
||||||
// TODO: check id and type if present in AST
|
// TODO: check id and type if present in AST
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -161,8 +157,8 @@ describe('Nodes (ported from mindmap.spec.ts)', () => {
|
|||||||
const result = parse('mindmap\nroot\n theId(child1)');
|
const result = parse('mindmap\nroot\n theId(child1)');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('root');
|
expect(result.value.rows[0].content).toBe('root');
|
||||||
expect(result.value.statements[1].content).toBe('child1');
|
expect(result.value.rows[1].content).toBe('child1');
|
||||||
// TODO: check id and type if present in AST
|
// TODO: check id and type if present in AST
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -170,7 +166,7 @@ describe('Nodes (ported from mindmap.spec.ts)', () => {
|
|||||||
const result = parse('mindmap\nroot((the root))');
|
const result = parse('mindmap\nroot((the root))');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('the root');
|
expect(result.value.rows[0].content).toBe('the root');
|
||||||
// TODO: check type if present in AST
|
// TODO: check type if present in AST
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -178,7 +174,7 @@ describe('Nodes (ported from mindmap.spec.ts)', () => {
|
|||||||
const result = parse('mindmap\nroot)the root(');
|
const result = parse('mindmap\nroot)the root(');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('the root');
|
expect(result.value.rows[0].content).toBe('the root');
|
||||||
// TODO: check type if present in AST
|
// TODO: check type if present in AST
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -186,7 +182,7 @@ describe('Nodes (ported from mindmap.spec.ts)', () => {
|
|||||||
const result = parse('mindmap\nroot))the root((');
|
const result = parse('mindmap\nroot))the root((');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('the root');
|
expect(result.value.rows[0].content).toBe('the root');
|
||||||
// TODO: check type if present in AST
|
// TODO: check type if present in AST
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -194,7 +190,7 @@ describe('Nodes (ported from mindmap.spec.ts)', () => {
|
|||||||
const result = parse('mindmap\nroot{{the root}}');
|
const result = parse('mindmap\nroot{{the root}}');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('the root');
|
expect(result.value.rows[0].content).toBe('the root');
|
||||||
// TODO: check type if present in AST
|
// TODO: check type if present in AST
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -205,28 +201,28 @@ describe('Decorations (ported from mindmap.spec.ts)', () => {
|
|||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
// TODO: check icon if present in AST
|
// TODO: check icon if present in AST
|
||||||
expect(result.value.statements[0].content).toBe('The root');
|
expect(result.value.rows[0].content).toBe('The root');
|
||||||
});
|
});
|
||||||
it('MMP-14 should be possible to set classes for the node', () => {
|
it('MMP-14 should be possible to set classes for the node', () => {
|
||||||
const result = parse('mindmap\nroot[The root]\n:::m-4 p-8');
|
const result = parse('mindmap\nroot[The root]\n:::m-4 p-8');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
// TODO: check class if present in AST
|
// TODO: check class if present in AST
|
||||||
expect(result.value.statements[0].content).toBe('The root');
|
expect(result.value.rows[0].content).toBe('The root');
|
||||||
});
|
});
|
||||||
it('MMP-15 should be possible to set both classes and icon for the node', () => {
|
it('MMP-15 should be possible to set both classes and icon for the node', () => {
|
||||||
const result = parse('mindmap\nroot[The root]\n:::m-4 p-8\n::icon(bomb)');
|
const result = parse('mindmap\nroot[The root]\n:::m-4 p-8\n::icon(bomb)');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
// TODO: check class and icon if present in AST
|
// TODO: check class and icon if present in AST
|
||||||
expect(result.value.statements[0].content).toBe('The root');
|
expect(result.value.rows[0].content).toBe('The root');
|
||||||
});
|
});
|
||||||
it('MMP-16 should be possible to set both classes and icon for the node (reverse order)', () => {
|
it('MMP-16 should be possible to set both classes and icon for the node (reverse order)', () => {
|
||||||
const result = parse('mindmap\nroot[The root]\n::icon(bomb)\n:::m-4 p-8');
|
const result = parse('mindmap\nroot[The root]\n::icon(bomb)\n:::m-4 p-8');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
// TODO: check class and icon if present in AST
|
// TODO: check class and icon if present in AST
|
||||||
expect(result.value.statements[0].content).toBe('The root');
|
expect(result.value.rows[0].content).toBe('The root');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -235,14 +231,14 @@ describe('Descriptions (ported from mindmap.spec.ts)', () => {
|
|||||||
const result = parse('mindmap\nroot["String containing []"]');
|
const result = parse('mindmap\nroot["String containing []"]');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('String containing []');
|
expect(result.value.rows[0].content).toBe('String containing []');
|
||||||
});
|
});
|
||||||
it('MMP-18 should be possible to use node syntax in the descriptions in children', () => {
|
it('MMP-18 should be possible to use node syntax in the descriptions in children', () => {
|
||||||
const result = parse('mindmap\nroot["String containing []"]\n child1["String containing ()"]');
|
const result = parse('mindmap\nroot["String containing []"]\n child1["String containing ()"]');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('String containing []');
|
expect(result.value.rows[0].content).toBe('String containing []');
|
||||||
expect(result.value.statements[1].content).toBe('String containing ()');
|
expect(result.value.rows[1].content).toBe('String containing ()');
|
||||||
});
|
});
|
||||||
it('MMP-19 should be possible to have a child after a class assignment', () => {
|
it('MMP-19 should be possible to have a child after a class assignment', () => {
|
||||||
const result = parse(
|
const result = parse(
|
||||||
@@ -250,10 +246,10 @@ describe('Descriptions (ported from mindmap.spec.ts)', () => {
|
|||||||
);
|
);
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('Root');
|
expect(result.value.rows[0].content).toBe('Root');
|
||||||
expect(result.value.statements[1].content).toBe('Child');
|
expect(result.value.rows[1].content).toBe('Child');
|
||||||
expect(result.value.statements[2].content).toBe('a');
|
expect(result.value.rows[2].content).toBe('a');
|
||||||
expect(result.value.statements[3].content).toBe('b');
|
expect(result.value.rows[3].content).toBe('b');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -262,10 +258,10 @@ describe('Miscellaneous (ported from mindmap.spec.ts)', () => {
|
|||||||
const result = parse('mindmap\nroot(Root)\n Child(Child)\n a(a)\n\n b[New Stuff]');
|
const result = parse('mindmap\nroot(Root)\n Child(Child)\n a(a)\n\n b[New Stuff]');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('Root');
|
expect(result.value.rows[0].content).toBe('Root');
|
||||||
expect(result.value.statements[1].content).toBe('Child');
|
expect(result.value.rows[1].content).toBe('Child');
|
||||||
expect(result.value.statements[2].content).toBe('a');
|
expect(result.value.rows[2].content).toBe('a');
|
||||||
expect(result.value.statements[3].content).toBe('b');
|
expect(result.value.rows[3].content).toBe('b');
|
||||||
});
|
});
|
||||||
it('MMP-21 should be possible to have comments in a mindmap', () => {
|
it('MMP-21 should be possible to have comments in a mindmap', () => {
|
||||||
const result = parse(
|
const result = parse(
|
||||||
@@ -273,10 +269,10 @@ describe('Miscellaneous (ported from mindmap.spec.ts)', () => {
|
|||||||
);
|
);
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('Root');
|
expect(result.value.rows[0].content).toBe('Root');
|
||||||
expect(result.value.statements[1].content).toBe('Child');
|
expect(result.value.rows[1].content).toBe('Child');
|
||||||
expect(result.value.statements[2].content).toBe('a');
|
expect(result.value.rows[2].content).toBe('a');
|
||||||
expect(result.value.statements[3].content).toBe('b');
|
expect(result.value.rows[3].content).toBe('b');
|
||||||
});
|
});
|
||||||
it('MMP-22 should be possible to have comments at the end of a line', () => {
|
it('MMP-22 should be possible to have comments at the end of a line', () => {
|
||||||
const result = parse(
|
const result = parse(
|
||||||
@@ -284,33 +280,33 @@ describe('Miscellaneous (ported from mindmap.spec.ts)', () => {
|
|||||||
);
|
);
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('Root');
|
expect(result.value.rows[0].content).toBe('Root');
|
||||||
expect(result.value.statements[1].content).toBe('Child');
|
expect(result.value.rows[1].content).toBe('Child');
|
||||||
expect(result.value.statements[2].content).toBe('a');
|
expect(result.value.rows[2].content).toBe('a');
|
||||||
expect(result.value.statements[3].content).toBe('b');
|
expect(result.value.rows[3].content).toBe('b');
|
||||||
});
|
});
|
||||||
it('MMP-23 Rows with only spaces should not interfere', () => {
|
it('MMP-23 Rows with only spaces should not interfere', () => {
|
||||||
const result = parse('mindmap\nroot\n A\n \n\n B');
|
const result = parse('mindmap\nroot\n A\n \n\n B');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('root');
|
expect(result.value.rows[0].content).toBe('root');
|
||||||
expect(result.value.statements[1].content).toBe('A');
|
expect(result.value.rows[1].content).toBe('A');
|
||||||
expect(result.value.statements[2].content).toBe('B');
|
expect(result.value.rows[2].content).toBe('B');
|
||||||
});
|
});
|
||||||
it('MMP-24 Handle rows above the mindmap declarations', () => {
|
it('MMP-24 Handle rows above the mindmap declarations', () => {
|
||||||
const result = parse('\n \nmindmap\nroot\n A\n \n\n B');
|
const result = parse('\n \nmindmap\nroot\n A\n \n\n B');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('root');
|
expect(result.value.rows[0].content).toBe('root');
|
||||||
expect(result.value.statements[1].content).toBe('A');
|
expect(result.value.rows[1].content).toBe('A');
|
||||||
expect(result.value.statements[2].content).toBe('B');
|
expect(result.value.rows[2].content).toBe('B');
|
||||||
});
|
});
|
||||||
it('MMP-25 Handle rows above the mindmap declarations, no space', () => {
|
it('MMP-25 Handle rows above the mindmap declarations, no space', () => {
|
||||||
const result = parse('\n\n\nmindmap\nroot\n A\n \n\n B');
|
const result = parse('\n\n\nmindmap\nroot\n A\n \n\n B');
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
expect(result.lexerErrors).toHaveLength(0);
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
expect(result.parserErrors).toHaveLength(0);
|
||||||
expect(result.value.statements[0].content).toBe('root');
|
expect(result.value.rows[0].content).toBe('root');
|
||||||
expect(result.value.statements[1].content).toBe('A');
|
expect(result.value.rows[1].content).toBe('A');
|
||||||
expect(result.value.statements[2].content).toBe('B');
|
expect(result.value.rows[2].content).toBe('B');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user