mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 23:39:50 +02:00
Merge branch 'develop' into UpdateClassMemberHandling
This commit is contained in:
@@ -268,6 +268,113 @@ class C13["With Città foreign language"]
|
||||
parser.parse(str);
|
||||
});
|
||||
|
||||
const keywords = [
|
||||
'direction',
|
||||
'classDiagram',
|
||||
'classDiagram-v2',
|
||||
'namespace',
|
||||
'{}',
|
||||
'{',
|
||||
'}',
|
||||
'()',
|
||||
'(',
|
||||
')',
|
||||
'[]',
|
||||
'[',
|
||||
']',
|
||||
'class',
|
||||
'\n',
|
||||
'cssClass',
|
||||
'callback',
|
||||
'link',
|
||||
'click',
|
||||
'note',
|
||||
'note for',
|
||||
'<<',
|
||||
'>>',
|
||||
'call ',
|
||||
'~',
|
||||
'~Generic~',
|
||||
'_self',
|
||||
'_blank',
|
||||
'_parent',
|
||||
'_top',
|
||||
'<|',
|
||||
'|>',
|
||||
'>',
|
||||
'<',
|
||||
'*',
|
||||
'o',
|
||||
'\\',
|
||||
'--',
|
||||
'..',
|
||||
'-->',
|
||||
'--|>',
|
||||
': label',
|
||||
':::',
|
||||
'.',
|
||||
'+',
|
||||
'alphaNum',
|
||||
'!',
|
||||
'0123',
|
||||
'function()',
|
||||
'function(arg1, arg2)',
|
||||
];
|
||||
|
||||
it.each(keywords)('should handle a note with %s in it', function (keyword: string) {
|
||||
const str = `classDiagram
|
||||
note "This is a keyword: ${keyword}. It truly is."
|
||||
`;
|
||||
parser.parse(str);
|
||||
expect(classDb.getNotes()[0].text).toEqual(`This is a keyword: ${keyword}. It truly is.`);
|
||||
});
|
||||
|
||||
it.each(keywords)(
|
||||
'should handle note with %s at beginning of string',
|
||||
function (keyword: string) {
|
||||
const str = `classDiagram
|
||||
note "${keyword}"`;
|
||||
|
||||
parser.parse(str);
|
||||
expect(classDb.getNotes()[0].text).toEqual(`${keyword}`);
|
||||
}
|
||||
);
|
||||
|
||||
it.each(keywords)('should handle a "note for" with a %s in it', function (keyword: string) {
|
||||
const str = `classDiagram
|
||||
class Something {
|
||||
int id
|
||||
string name
|
||||
}
|
||||
note for Something "This is a keyword: ${keyword}. It truly is."
|
||||
`;
|
||||
|
||||
parser.parse(str);
|
||||
expect(classDb.getNotes()[0].text).toEqual(`This is a keyword: ${keyword}. It truly is.`);
|
||||
});
|
||||
|
||||
it.each(keywords)(
|
||||
'should handle a "note for" with a %s at beginning of string',
|
||||
function (keyword: string) {
|
||||
const str = `classDiagram
|
||||
class Something {
|
||||
int id
|
||||
string name
|
||||
}
|
||||
note for Something "${keyword}"
|
||||
`;
|
||||
|
||||
parser.parse(str);
|
||||
expect(classDb.getNotes()[0].text).toEqual(`${keyword}`);
|
||||
}
|
||||
);
|
||||
|
||||
it.each(keywords)('should elicit error for %s after NOTE token', function (keyword: string) {
|
||||
const str = `classDiagram
|
||||
note ${keyword}`;
|
||||
expect(() => parser.parse(str)).toThrowError(/(Expecting\s'STR'|Unrecognized\stext)/);
|
||||
});
|
||||
|
||||
it('should parse diagram with direction', () => {
|
||||
parser.parse(`classDiagram
|
||||
direction TB
|
||||
|
Reference in New Issue
Block a user