Skip to content

Commit

Permalink
chore: address @Yokozuna59's code reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash-Singh1 committed May 15, 2024
1 parent 2df26ca commit dd92aec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 29 deletions.
10 changes: 1 addition & 9 deletions packages/mermaid/src/diagrams/class/parser/class.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,9 @@ describe('class diagram', 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\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');
});
});
});
23 changes: 8 additions & 15 deletions packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,20 +794,13 @@ describe('when parsing ER diagram it...', function () {
});

describe('prototype properties', function () {
function validateProperty(prop) {
expect(() => erDiagram.parser.parse(`erDiagram\n${prop} ||--|{ ORDER : place`)).not.toThrow();
}

it('should work with a prototype property', function () {
validateProperty('prototype');
});

it('should work with a __proto__ property', function () {
validateProperty('__proto__');
});

it('should work with a constructor property', function () {
validateProperty('constructor');
});
it.each(['__proto__', 'constructor', 'prototype'])(
'should work with a %s property',
function (prop) {
expect(() =>
erDiagram.parser.parse(`erDiagram\n${prop} ||--|{ ORDER : place`)
).not.toThrow();
}
);
});
});
6 changes: 3 additions & 3 deletions packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ describe('flow db addClass', () => {

expect(classes.has('a')).toBe(true);
expect(classes.has('b')).toBe(true);
expect(classes.get('a')?.['styles']).toEqual(['stroke-width: 8px']);
expect(classes.get('b')?.['styles']).toEqual(['stroke-width: 8px']);
expect(classes.get('a')?.styles).toEqual(['stroke-width: 8px']);
expect(classes.get('b')?.styles).toEqual(['stroke-width: 8px']);
});

it('should detect single class', () => {
flowDb.addClass('a', ['stroke-width: 8px']);
const classes = flowDb.getClasses();

expect(classes.has('a')).toBe(true);
expect(classes.get('a')?.['styles']).toEqual(['stroke-width: 8px']);
expect(classes.get('a')?.styles).toEqual(['stroke-width: 8px']);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ Bob-->Alice-in-Wonderland:I am good thanks!`;

await mermaidAPI.parse(str);
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('Bob').description).toBe('Bob');

Expand All @@ -371,7 +371,7 @@ B-->A: I am good thanks!`;

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('B').description).toBe('Bob');

Expand Down

0 comments on commit dd92aec

Please sign in to comment.