mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
feat: #2685 Support class member initialization by member definition
This commit is contained in:
parent
eca0cea339
commit
c3df18fc5b
@ -174,6 +174,8 @@ export const addAnnotation = function (className: string, annotation: string) {
|
||||
* @public
|
||||
*/
|
||||
export const addMember = function (className: string, member: string) {
|
||||
addClass(className);
|
||||
|
||||
const validatedClassName = splitClassNameAndType(className).className;
|
||||
const theClass = classes[validatedClassName];
|
||||
|
||||
|
@ -742,6 +742,22 @@ describe('given a class diagram with members and methods ', function () {
|
||||
parser.parse(str);
|
||||
});
|
||||
|
||||
it('should handle direct member declaration', function () {
|
||||
const str = 'classDiagram\n' + 'Car : wheels';
|
||||
|
||||
parser.parse(str);
|
||||
expect(classDb.getClasses()).toHaveProperty('Car');
|
||||
expect(classDb.getClasses()['Car']['members']).toContain('wheels');
|
||||
});
|
||||
|
||||
it('should handle direct member declaration with type', function () {
|
||||
const str = 'classDiagram\n' + 'Car : int wheels';
|
||||
|
||||
parser.parse(str);
|
||||
expect(classDb.getClasses()).toHaveProperty('Car');
|
||||
expect(classDb.getClasses()['Car']['members']).toContain('int wheels');
|
||||
});
|
||||
|
||||
it('should handle simple member declaration with type', function () {
|
||||
const str = 'classDiagram\n' + 'class Car\n' + 'Car : int wheels';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user