diff --git a/packages/mermaid/src/diagrams/class/parser/class.spec.js b/packages/mermaid/src/diagrams/class/parser/class.spec.js index d5f1de276c..d611dfc02d 100644 --- a/packages/mermaid/src/diagrams/class/parser/class.spec.js +++ b/packages/mermaid/src/diagrams/class/parser/class.spec.js @@ -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'); }); }); }); diff --git a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js index bb747dcc67..e36454f313 100644 --- a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js +++ b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js @@ -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(); + } + ); }); }); diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts b/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts index 464faa1824..5983bf04cd 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts @@ -53,8 +53,8 @@ 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', () => { @@ -62,6 +62,6 @@ describe('flow db addClass', () => { 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']); }); }); diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js index 5fd4ef4cad..97d528df63 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js +++ b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js @@ -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'); @@ -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');