mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-14 21:09:50 +02:00
fix: Class with members and styles
This commit is contained in:
@@ -190,6 +190,37 @@ describe('class diagram, ', function () {
|
||||
parser.parse(str);
|
||||
});
|
||||
|
||||
it('should handle cssClass shorthand with members', () => {
|
||||
parser.parse(`classDiagram-v2
|
||||
class Class10:::exClass2 {
|
||||
int[] id
|
||||
List~int~ ids
|
||||
test(List~int~ ids) List~bool~
|
||||
testArray() bool[]
|
||||
}`);
|
||||
|
||||
expect(classDb.getClass('Class10')).toMatchInlineSnapshot(`
|
||||
{
|
||||
"annotations": [],
|
||||
"cssClasses": [
|
||||
"exClass2",
|
||||
],
|
||||
"domId": "classId-Class10-27",
|
||||
"id": "Class10",
|
||||
"label": "Class10",
|
||||
"members": [
|
||||
"int[] id",
|
||||
"List~int~ ids",
|
||||
],
|
||||
"methods": [
|
||||
"test(List~int~ ids) List~bool~",
|
||||
"testArray() bool[]",
|
||||
],
|
||||
"type": "",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it('should handle method statements', function () {
|
||||
const str =
|
||||
'classDiagram\n' +
|
||||
@@ -1023,6 +1054,7 @@ C1 --> C2
|
||||
const c1 = classDb.getClass('C1');
|
||||
expect(c1.label).toBe('Class 1 with text label');
|
||||
expect(c1.cssClasses.length).toBe(1);
|
||||
expect(c1.members[0]).toBe('+member1');
|
||||
expect(c1.cssClasses[0]).toBe('styleClass');
|
||||
});
|
||||
|
||||
@@ -1038,6 +1070,7 @@ cssClass "C1" styleClass
|
||||
const c1 = classDb.getClass('C1');
|
||||
expect(c1.label).toBe('Class 1 with text label');
|
||||
expect(c1.cssClasses.length).toBe(1);
|
||||
expect(c1.members[0]).toBe('+member1');
|
||||
expect(c1.cssClasses[0]).toBe('styleClass');
|
||||
});
|
||||
|
||||
|
@@ -283,7 +283,7 @@ classStatement
|
||||
: classIdentifier
|
||||
| classIdentifier STYLE_SEPARATOR alphaNumToken {yy.setCssClass($1, $3);}
|
||||
| classIdentifier STRUCT_START members STRUCT_STOP {yy.addMembers($1,$3);}
|
||||
| classIdentifier STYLE_SEPARATOR alphaNumToken STRUCT_START members STRUCT_STOP {yy.setCssClass($1, $3);yy.addMembers($1,$3);}
|
||||
| classIdentifier STYLE_SEPARATOR alphaNumToken STRUCT_START members STRUCT_STOP {yy.setCssClass($1, $3);yy.addMembers($1,$5);}
|
||||
;
|
||||
|
||||
classIdentifier
|
||||
|
Reference in New Issue
Block a user