mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-02-04 07:13:25 +08:00
chore: address @Yokozuna59's code reviews
This commit is contained in:
parent
2df26ca323
commit
dd92aecdca
@ -8,17 +8,9 @@ describe('class diagram', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('prototype properties', function () {
|
describe('prototype properties', function () {
|
||||||
function validateProperty(prop) {
|
it.each(['__proto__', 'constructor'])('should work with a %s property', function (prop) {
|
||||||
expect(() => parser.parse(`classDiagram\nclass ${prop}`)).not.toThrow();
|
expect(() => parser.parse(`classDiagram\nclass ${prop}`)).not.toThrow();
|
||||||
expect(() => parser.parse(`classDiagram\nnamespace ${prop} {\n\tclass A\n}`)).not.toThrow();
|
expect(() => parser.parse(`classDiagram\nnamespace ${prop} {\n\tclass A\n}`)).not.toThrow();
|
||||||
}
|
|
||||||
|
|
||||||
it('should work with a __proto__ property', function () {
|
|
||||||
validateProperty('__proto__');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work with a constructor property', function () {
|
|
||||||
validateProperty('constructor');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -794,20 +794,13 @@ describe('when parsing ER diagram it...', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('prototype properties', function () {
|
describe('prototype properties', function () {
|
||||||
function validateProperty(prop) {
|
it.each(['__proto__', 'constructor', 'prototype'])(
|
||||||
expect(() => erDiagram.parser.parse(`erDiagram\n${prop} ||--|{ ORDER : place`)).not.toThrow();
|
'should work with a %s property',
|
||||||
}
|
function (prop) {
|
||||||
|
expect(() =>
|
||||||
it('should work with a prototype property', function () {
|
erDiagram.parser.parse(`erDiagram\n${prop} ||--|{ ORDER : place`)
|
||||||
validateProperty('prototype');
|
).not.toThrow();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
it('should work with a __proto__ property', function () {
|
|
||||||
validateProperty('__proto__');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work with a constructor property', function () {
|
|
||||||
validateProperty('constructor');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -53,8 +53,8 @@ describe('flow db addClass', () => {
|
|||||||
|
|
||||||
expect(classes.has('a')).toBe(true);
|
expect(classes.has('a')).toBe(true);
|
||||||
expect(classes.has('b')).toBe(true);
|
expect(classes.has('b')).toBe(true);
|
||||||
expect(classes.get('a')?.['styles']).toEqual(['stroke-width: 8px']);
|
expect(classes.get('a')?.styles).toEqual(['stroke-width: 8px']);
|
||||||
expect(classes.get('b')?.['styles']).toEqual(['stroke-width: 8px']);
|
expect(classes.get('b')?.styles).toEqual(['stroke-width: 8px']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should detect single class', () => {
|
it('should detect single class', () => {
|
||||||
@ -62,6 +62,6 @@ describe('flow db addClass', () => {
|
|||||||
const classes = flowDb.getClasses();
|
const classes = flowDb.getClasses();
|
||||||
|
|
||||||
expect(classes.has('a')).toBe(true);
|
expect(classes.has('a')).toBe(true);
|
||||||
expect(classes.get('a')?.['styles']).toEqual(['stroke-width: 8px']);
|
expect(classes.get('a')?.styles).toEqual(['stroke-width: 8px']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -348,7 +348,7 @@ Bob-->Alice-in-Wonderland:I am good thanks!`;
|
|||||||
|
|
||||||
await mermaidAPI.parse(str);
|
await mermaidAPI.parse(str);
|
||||||
const actors = diagram.db.getActors();
|
const actors = diagram.db.getActors();
|
||||||
expect([...actors.keys()].sort()).toEqual(['Alice-in-Wonderland', 'Bob']);
|
expect([...actors.keys()]).toEqual(['Alice-in-Wonderland', 'Bob']);
|
||||||
expect(actors.get('Alice-in-Wonderland').description).toBe('Alice-in-Wonderland');
|
expect(actors.get('Alice-in-Wonderland').description).toBe('Alice-in-Wonderland');
|
||||||
expect(actors.get('Bob').description).toBe('Bob');
|
expect(actors.get('Bob').description).toBe('Bob');
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ B-->A: I am good thanks!`;
|
|||||||
|
|
||||||
const actors = diagram.db.getActors();
|
const actors = diagram.db.getActors();
|
||||||
|
|
||||||
expect([...actors.keys()].sort()).toEqual(['A', 'B']);
|
expect([...actors.keys()]).toEqual(['A', 'B']);
|
||||||
expect(actors.get('A').description).toBe('Alice');
|
expect(actors.get('A').description).toBe('Alice');
|
||||||
expect(actors.get('B').description).toBe('Bob');
|
expect(actors.get('B').description).toBe('Bob');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user