@@ -513,7 +513,7 @@ flowchart LR
### Styling links
-It is possible to style links. For instance you might want to style a link that is going backwards in the flow. As links
+It is possible to style links. For instance, you might want to style a link that is going backwards in the flow. As links
have no ids in the same way as nodes, some other way of deciding what style the links should be attached to is required.
Instead of ids, the order number of when the link was defined in the graph is used, or use default to apply to all links.
In the example below the style defined in the linkStyle statement will belong to the fourth link in the graph:
diff --git a/docs/gantt.md b/docs/gantt.md
index 2dca82325..0207412c0 100644
--- a/docs/gantt.md
+++ b/docs/gantt.md
@@ -313,7 +313,7 @@ click taskId href URL
* taskId is the id of the task
* callback is the name of a javascript function defined on the page displaying the graph, the function will be called with the taskId as the parameter if no other arguments are specified.
-Beginners tip, a full example using interactive links in an html context:
+Beginner's tip—a full example using interactive links in an html context:
```html
diff --git a/docs/n00b-syntaxReference.md b/docs/n00b-syntaxReference.md
index 9cd9a9025..d10918be2 100644
--- a/docs/n00b-syntaxReference.md
+++ b/docs/n00b-syntaxReference.md
@@ -8,7 +8,7 @@ Diagram Examples can be found in the [Mermaid Live Editor](https://mermaid-js.gi
## Syntax Structure
One would notice that all **Diagrams definitions begin** with a declaration of the **diagram type**, followed by the definitions of the diagram and its contents. This declaration notifies the parser which kind of diagram the code is supposed to generate.
-**Example** : The code below is for an Entity Relationship Diagram, specified by the `erDiagram` declaration. What follows is the definition of the different `Entities` represented in it.
+**Example** : The code below is for an Entity Relationship Diagram, specified by the `erDiagram` declaration. What follows is the definition of the different `Entities` represented in it.
```mermaid-example
erDiagram
diff --git a/docs/theming.md b/docs/theming.md
index e64432445..d61f02bdc 100644
--- a/docs/theming.md
+++ b/docs/theming.md
@@ -64,7 +64,7 @@ Here is an example of how `%%init%%` can set the theme to 'base', this assumes t
```
# List of Themes
-# Customizing Themes with `themeVariables`
+# Customizing Themes with `themeVariables`
The easiest way to make a custom theme is to start with the base theme, and just modify theme variables through `themeVariables`, via `%%init%%`.
diff --git a/docs/usage.md b/docs/usage.md
index ac126631a..1815f0a36 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -107,7 +107,7 @@ Mermaid can load multiple diagrams, in the same page.
| Parameter | Description | Type | Required | Values |
| ------------- | --------------------------------- | ------ | -------- | ------------------------- |
-| securityLevel | Level of trust for parsed diagram | String | Required | Strict, Loose, antiscript , sandbox|
+| securityLevel | Level of trust for parsed diagram | String | Required | 'sandbox', 'strict', 'loose', 'antiscript' |
Values:
@@ -118,7 +118,7 @@ Values:
```note
-This changes the default behaviour of mermaid so that after upgrade to 8.2,unless the `securityLevel` is not changed, tags in flowcharts are encoded as tags and clicking is disabled.
+This changes the default behaviour of mermaid so that after upgrade to 8.2, unless the `securityLevel` is not changed, tags in flowcharts are encoded as tags and clicking is disabled.
**sandbox** security level is still in the beta version.
```
diff --git a/package.json b/package.json
index 7185e73f5..a122f9285 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,7 @@
"postbuild": "documentation build src/mermaidAPI.ts src/config.ts src/defaultConfig.ts --shallow -f md --markdown-toc false > docs/Setup.md",
"build:watch": "yarn build:dev --watch",
"release": "yarn build",
- "lint": "eslint ./ --ext .js,.json,.html",
+ "lint": "eslint ./ --ext .js,.json,.html,.md",
"lint:fix": "yarn lint --fix",
"e2e:depr": "yarn lint && jest e2e --config e2e/jest.config.js",
"cypress": "cypress run",
diff --git a/src/dagre-wrapper/mermaid-graphlib.spec.js b/src/dagre-wrapper/mermaid-graphlib.spec.js
index 2c502cbc3..8155bbf70 100644
--- a/src/dagre-wrapper/mermaid-graphlib.spec.js
+++ b/src/dagre-wrapper/mermaid-graphlib.spec.js
@@ -471,7 +471,7 @@ describe('sortNodesByHierarchy', function () {
return {};
});
});
- it('it should sort proper en nodes are in reverse order', function () {
+ it('should sort proper en nodes are in reverse order', function () {
/*
a -->b
subgraph B
@@ -488,7 +488,7 @@ describe('sortNodesByHierarchy', function () {
g.setEdge('a', 'b', '1');
expect(sortNodesByHierarchy(g)).toEqual(['a', 'A', 'B', 'b']);
});
- it('it should sort proper en nodes are in correct order', function () {
+ it('should sort proper en nodes are in correct order', function () {
/*
a -->b
subgraph B
diff --git a/src/defaultConfig.ts b/src/defaultConfig.ts
index c6b2cad9e..1c1566467 100644
--- a/src/defaultConfig.ts
+++ b/src/defaultConfig.ts
@@ -66,9 +66,9 @@ const config: Partial
= {
logLevel: 5,
/**
- * | Parameter | Description | Type | Required | Values |
- * | ------------- | --------------------------------- | ------ | -------- | ------------------------------- |
- * | securitylevel | Level of trust for parsed diagram | string | Required | 'strict', 'loose', 'antiscript' |
+ * | Parameter | Description | Type | Required | Values |
+ * | ------------- | --------------------------------- | ------ | -------- | ------------------------------------------ |
+ * | securityLevel | Level of trust for parsed diagram | string | Required | 'sandbox', 'strict', 'loose', 'antiscript' |
*
* **Notes**:
*
@@ -76,6 +76,9 @@ const config: Partial = {
* - **loose**: tags in text are allowed, click functionality is enabled
* - **antiscript**: html tags in text are allowed, (only script element is removed), click
* functionality is enabled
+ * - **sandbox**: With this security level all rendering takes place in a sandboxed iframe. This
+ * prevent any JavaScript from running in the context. This may hinder interactive functionality
+ * of the diagram like scripts, popups in sequence diagram or links to other tabs/targets etc.
*/
securityLevel: 'strict',
diff --git a/src/diagrams/c4/parser/flow.spec.js b/src/diagrams/c4/parser/flow.spec.js
new file mode 100644
index 000000000..c01d99e40
--- /dev/null
+++ b/src/diagrams/c4/parser/flow.spec.js
@@ -0,0 +1,84 @@
+import flowDb from '../c4Db';
+import flow from './c4Diagram.jison';
+import { setConfig } from '../../../config';
+
+setConfig({
+ securityLevel: 'strict',
+});
+
+describe('parsing a flow chart', function () {
+ beforeEach(function () {
+ flow.parser.yy = flowDb;
+ flow.parser.yy.clear();
+ });
+
+ it('should parse a C4 diagram with one Person correctly', function () {
+ flow.parser.parse(`C4Context
+title System Context diagram for Internet Banking System
+Person(customerA, "Banking Customer A", "A customer of the bank, with personal bank accounts.")`);
+
+ const yy = flow.parser.yy;
+ expect(yy.getC4Type()).toBe('C4Context');
+ expect(yy.getTitle()).toBe('System Context diagram for Internet Banking System');
+
+ const shapes = yy.getC4ShapeArray();
+ expect(shapes.length).toBe(1);
+ const onlyShape = shapes[0];
+
+ expect(onlyShape).toEqual({
+ alias: 'customerA',
+ descr: {
+ text: 'A customer of the bank, with personal bank accounts.',
+ },
+ label: {
+ text: 'Banking Customer A',
+ },
+ parentBoundary: 'global',
+ typeC4Shape: {
+ text: 'person',
+ },
+ wrap: false,
+ });
+ });
+
+ it('should handle a trailing whitespaces after statements', function () {
+ const whitespace = ' ';
+ const rendered = flow.parser.parse(`C4Context${whitespace}
+title System Context diagram for Internet Banking System${whitespace}
+Person(customerA, "Banking Customer A", "A customer of the bank, with personal bank accounts.")${whitespace}`);
+
+ expect(rendered).toBe(true);
+ });
+
+ it('should handle parameter names that are keywords', function () {
+ flow.parser.parse(`C4Context
+title title
+Person(Person, "Person", "Person")`);
+
+ const yy = flow.parser.yy;
+ expect(yy.getTitle()).toBe('title');
+
+ const shapes = yy.getC4ShapeArray();
+ expect(shapes.length).toBe(1);
+ const onlyShape = shapes[0];
+
+ expect(onlyShape.alias).toBe('Person');
+ expect(onlyShape.descr.text).toBe('Person');
+ expect(onlyShape.label.text).toBe('Person');
+ });
+
+ it('should allow default in the parameters', function () {
+ flow.parser.parse(`C4Context
+Person(default, "default", "default")`);
+
+ const yy = flow.parser.yy;
+
+ const shapes = yy.getC4ShapeArray();
+ expect(shapes.length).toBe(1);
+ const onlyShape = shapes[0];
+
+ expect(onlyShape.alias).toBe('default');
+ expect(onlyShape.descr.text).toBe('default');
+ expect(onlyShape.label.text).toBe('default');
+ });
+});
diff --git a/src/diagrams/class/svgDraw.js b/src/diagrams/class/svgDraw.js
index a6b11cd95..b9d31772a 100644
--- a/src/diagrams/class/svgDraw.js
+++ b/src/diagrams/class/svgDraw.js
@@ -1,6 +1,7 @@
import { line, curveBasis } from 'd3';
import utils from '../../utils';
import { log } from '../../logger';
+import { parseGenericTypes } from '../common/common';
let edgeCount = 0;
export const drawEdge = function (elem, path, relation, conf, diagObj) {
@@ -412,29 +413,6 @@ const addTspan = function (textEl, txt, isFirst, conf) {
}
};
-/**
- * Makes generics in typescript syntax
- *
- * @example Array of array of strings in typescript syntax
- * // returns "Array>"
- * parseGenericTypes('Array~Array~string~~');
- *
- * @param {string} text The text to convert
- * @returns {string} The converted string
- */
-const parseGenericTypes = function (text) {
- let cleanedText = text;
-
- if (text.indexOf('~') != -1) {
- cleanedText = cleanedText.replace('~', '<');
- cleanedText = cleanedText.replace('~', '>');
-
- return parseGenericTypes(cleanedText);
- } else {
- return cleanedText;
- }
-};
-
/**
* Gives the styles for a classifier
*
diff --git a/src/diagrams/common/common.spec.js b/src/diagrams/common/common.spec.js
index 66ac7b2ea..275e5e753 100644
--- a/src/diagrams/common/common.spec.js
+++ b/src/diagrams/common/common.spec.js
@@ -1,4 +1,4 @@
-import { sanitizeText, removeScript } from './common';
+import { sanitizeText, removeScript, parseGenericTypes } from './common';
describe('when securityLevel is antiscript, all script must be removed', function () {
/**
@@ -57,3 +57,10 @@ describe('Sanitize text', function () {
expect(result).not.toContain('javascript:alert(1)');
});
});
+
+describe('generic parser', function () {
+ it('should parse generic types', function () {
+ expect(parseGenericTypes('test~T~')).toEqual('test');
+ expect(parseGenericTypes('test~Array~Array~string~~~')).toEqual('test>>');
+ });
+});
diff --git a/src/diagrams/common/common.ts b/src/diagrams/common/common.ts
index f88de5d57..7421f48a2 100644
--- a/src/diagrams/common/common.ts
+++ b/src/diagrams/common/common.ts
@@ -134,6 +134,29 @@ const getUrl = (useAbsolute: boolean): string => {
export const evaluate = (val: string | boolean): boolean =>
val === 'false' || val === false ? false : true;
+/**
+ * Makes generics in typescript syntax
+ *
+ * @example Array of array of strings in typescript syntax
+ * // returns "Array>"
+ * parseGenericTypes('Array~Array~string~~');
+ *
+ * @param {string} text The text to convert
+ * @returns {string} The converted string
+ */
+export const parseGenericTypes = function (text: string): string {
+ let cleanedText = text;
+
+ if (text.indexOf('~') != -1) {
+ cleanedText = cleanedText.replace('~', '<');
+ cleanedText = cleanedText.replace('~', '>');
+
+ return parseGenericTypes(cleanedText);
+ } else {
+ return cleanedText;
+ }
+};
+
export default {
getRows,
sanitizeText,
diff --git a/src/diagrams/er/erRenderer.js b/src/diagrams/er/erRenderer.js
index 6c2de26db..5b5e4de80 100644
--- a/src/diagrams/er/erRenderer.js
+++ b/src/diagrams/er/erRenderer.js
@@ -8,6 +8,7 @@ import { log } from '../../logger';
import erMarkers from './erMarkers';
import { configureSvgSize } from '../../utils';
import addSVGAccessibilityFields from '../../accessibility';
+import { parseGenericTypes } from '../common/common';
let conf = {};
@@ -63,6 +64,8 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
const attrPrefix = `${entityTextNode.node().id}-attr-${attrNum}`;
let nodeHeight = 0;
+ const attributeType = parseGenericTypes(item.attributeType);
+
// Add a text node for the attribute type
const typeNode = groupNode
.append('text')
@@ -76,7 +79,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
'style',
'font-family: ' + getConfig().fontFamily + '; font-size: ' + attrFontSize + 'px'
)
- .text(item.attributeType);
+ .text(attributeType);
// Add a text node for the attribute name
const nameNode = groupNode
diff --git a/src/diagrams/er/parser/erDiagram.jison b/src/diagrams/er/parser/erDiagram.jison
index 64d395aed..ceae4f18c 100644
--- a/src/diagrams/er/parser/erDiagram.jison
+++ b/src/diagrams/er/parser/erDiagram.jison
@@ -29,7 +29,8 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
"{" { this.begin("block"); return 'BLOCK_START'; }
\s+ /* skip whitespace in block */
\b((?:PK)|(?:FK))\b return 'ATTRIBUTE_KEY'
-[A-Za-z][A-Za-z0-9\-_]* return 'ATTRIBUTE_WORD'
+(.*?)[~](.*?)*[~] return 'ATTRIBUTE_WORD';
+[A-Za-z][A-Za-z0-9\-_\[\]]* return 'ATTRIBUTE_WORD'
\"[^"]*\" return 'COMMENT';
[\n]+ /* nothing */
"}" { this.popState(); return 'BLOCK_STOP'; }
diff --git a/src/diagrams/er/parser/erDiagram.spec.js b/src/diagrams/er/parser/erDiagram.spec.js
index 1e0a40104..409176f78 100644
--- a/src/diagrams/er/parser/erDiagram.spec.js
+++ b/src/diagrams/er/parser/erDiagram.spec.js
@@ -85,6 +85,31 @@ describe('when parsing ER diagram it...', function () {
expect(entities[entity].attributes.length).toBe(3);
});
+ it('should allow an entity with attribute that has a generic type', function () {
+ const entity = 'BOOK';
+ const attribute1 = 'type~T~ type';
+ const attribute2 = 'option~T~ readable "comment"';
+ const attribute3 = 'string id PK';
+
+ erDiagram.parser.parse(
+ `erDiagram\n${entity} {\n${attribute1}\n${attribute2}\n${attribute3}\n}`
+ );
+ const entities = erDb.getEntities();
+ expect(Object.keys(entities).length).toBe(1);
+ expect(entities[entity].attributes.length).toBe(3);
+ });
+
+ it('should allow an entity with attribute that is an array', function () {
+ const entity = 'BOOK';
+ const attribute1 = 'string[] readers FK "comment"';
+ const attribute2 = 'string[] authors FK';
+
+ erDiagram.parser.parse(`erDiagram\n${entity} {\n${attribute1}\n${attribute2}\n}`);
+ const entities = erDb.getEntities();
+ expect(Object.keys(entities).length).toBe(1);
+ expect(entities[entity].attributes.length).toBe(2);
+ });
+
it('should allow an entity with multiple attributes to be defined', function () {
const entity = 'BOOK';
const attribute1 = 'string title';
diff --git a/src/diagrams/flowchart/parser/flow-interactions.spec.js b/src/diagrams/flowchart/parser/flow-interactions.spec.js
index 8efffc62c..34125b153 100644
--- a/src/diagrams/flowchart/parser/flow-interactions.spec.js
+++ b/src/diagrams/flowchart/parser/flow-interactions.spec.js
@@ -14,7 +14,7 @@ describe('[Interactions] when parsing', () => {
flow.parser.yy.clear();
});
- it('it should be possible to use click to a callback', function () {
+ it('should be possible to use click to a callback', function () {
spyOn(flowDb, 'setClickEvent');
const res = flow.parser.parse('graph TD\nA-->B\nclick A callback');
@@ -24,7 +24,7 @@ describe('[Interactions] when parsing', () => {
expect(flowDb.setClickEvent).toHaveBeenCalledWith('A', 'callback');
});
- it('it should be possible to use click to a click and call callback', function () {
+ it('should be possible to use click to a click and call callback', function () {
spyOn(flowDb, 'setClickEvent');
const res = flow.parser.parse('graph TD\nA-->B\nclick A call callback()');
@@ -34,7 +34,7 @@ describe('[Interactions] when parsing', () => {
expect(flowDb.setClickEvent).toHaveBeenCalledWith('A', 'callback');
});
- it('it should be possible to use click to a callback with toolip', function () {
+ it('should be possible to use click to a callback with toolip', function () {
spyOn(flowDb, 'setClickEvent');
spyOn(flowDb, 'setTooltip');
const res = flow.parser.parse('graph TD\nA-->B\nclick A callback "tooltip"');
@@ -46,7 +46,7 @@ describe('[Interactions] when parsing', () => {
expect(flowDb.setTooltip).toHaveBeenCalledWith('A', 'tooltip');
});
- it('it should be possible to use click to a click and call callback with toolip', function () {
+ it('should be possible to use click to a click and call callback with toolip', function () {
spyOn(flowDb, 'setClickEvent');
spyOn(flowDb, 'setTooltip');
const res = flow.parser.parse('graph TD\nA-->B\nclick A call callback() "tooltip"');
@@ -58,7 +58,7 @@ describe('[Interactions] when parsing', () => {
expect(flowDb.setTooltip).toHaveBeenCalledWith('A', 'tooltip');
});
- it('it should be possible to use click to a callback with an arbitrary number of args', function () {
+ it('should be possible to use click to a callback with an arbitrary number of args', function () {
spyOn(flowDb, 'setClickEvent');
const res = flow.parser.parse('graph TD\nA-->B\nclick A call callback("test0", test1, test2)');
diff --git a/src/diagrams/flowchart/parser/flow-lines.spec.js b/src/diagrams/flowchart/parser/flow-lines.spec.js
index 9de243556..0fd1e9e9c 100644
--- a/src/diagrams/flowchart/parser/flow-lines.spec.js
+++ b/src/diagrams/flowchart/parser/flow-lines.spec.js
@@ -89,7 +89,7 @@ describe('[Lines] when parsing', () => {
});
describe('it should handle new line type notation', function () {
- it('it should handle regular lines', function () {
+ it('should handle regular lines', function () {
const res = flow.parser.parse('graph TD;A-->B;');
const vert = flow.parser.yy.getVertices();
@@ -98,7 +98,7 @@ describe('[Lines] when parsing', () => {
expect(edges[0].stroke).toBe('normal');
});
- it('it should handle dotted lines', function () {
+ it('should handle dotted lines', function () {
const res = flow.parser.parse('graph TD;A-.->B;');
const vert = flow.parser.yy.getVertices();
@@ -107,7 +107,7 @@ describe('[Lines] when parsing', () => {
expect(edges[0].stroke).toBe('dotted');
});
- it('it should handle dotted lines', function () {
+ it('should handle dotted lines', function () {
const res = flow.parser.parse('graph TD;A==>B;');
const vert = flow.parser.yy.getVertices();
diff --git a/src/diagrams/flowchart/parser/flow-text.spec.js b/src/diagrams/flowchart/parser/flow-text.spec.js
index 41dc9d509..e58d76780 100644
--- a/src/diagrams/flowchart/parser/flow-text.spec.js
+++ b/src/diagrams/flowchart/parser/flow-text.spec.js
@@ -13,7 +13,7 @@ describe('[Text] when parsing', () => {
});
describe('it should handle text on edges', function () {
- it('it should handle text without space', function () {
+ it('should handle text without space', function () {
const res = flow.parser.parse('graph TD;A--x|textNoSpace|B;');
const vert = flow.parser.yy.getVertices();
@@ -22,7 +22,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].type).toBe('arrow_cross');
});
- it('should handle with space', function () {
+ it('should handle with space', function () {
const res = flow.parser.parse('graph TD;A--x|text including space|B;');
const vert = flow.parser.yy.getVertices();
@@ -31,7 +31,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].type).toBe('arrow_cross');
});
- it('it should handle text with /', function () {
+ it('should handle text with /', function () {
const res = flow.parser.parse('graph TD;A--x|text with / should work|B;');
const vert = flow.parser.yy.getVertices();
@@ -40,7 +40,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].text).toBe('text with / should work');
});
- it('it should handle space and space between vertices and link', function () {
+ it('should handle space and space between vertices and link', function () {
const res = flow.parser.parse('graph TD;A --x|textNoSpace| B;');
const vert = flow.parser.yy.getVertices();
@@ -159,12 +159,6 @@ describe('[Text] when parsing', () => {
const edges = flow.parser.yy.getEdges();
expect(vert['a'].text).toBe('v');
});
- it('should handle keywords', function () {
- const res = flow.parser.parse('graph TD;V-->a[v]');
- const vert = flow.parser.yy.getVertices();
- const edges = flow.parser.yy.getEdges();
- expect(vert['a'].text).toBe('v');
- });
it('should handle quoted text', function () {
const res = flow.parser.parse('graph TD;V-- "test string()" -->a[v]');
const vert = flow.parser.yy.getVertices();
@@ -174,7 +168,7 @@ describe('[Text] when parsing', () => {
});
describe('it should handle text on lines', () => {
- it('it should handle normal text on lines', function () {
+ it('should handle normal text on lines', function () {
const res = flow.parser.parse('graph TD;A-- test text with == -->B;');
const vert = flow.parser.yy.getVertices();
@@ -182,7 +176,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].stroke).toBe('normal');
});
- it('it should handle dotted text on lines (TD3)', function () {
+ it('should handle dotted text on lines (TD3)', function () {
const res = flow.parser.parse('graph TD;A-. test text with == .->B;');
const vert = flow.parser.yy.getVertices();
@@ -190,7 +184,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].stroke).toBe('dotted');
});
- it('it should handle thick text on lines', function () {
+ it('should handle thick text on lines', function () {
const res = flow.parser.parse('graph TD;A== test text with - ==>B;');
const vert = flow.parser.yy.getVertices();
@@ -201,7 +195,7 @@ describe('[Text] when parsing', () => {
});
describe('it should handle text on edges using the new notation', function () {
- it('it should handle text without space', function () {
+ it('should handle text without space', function () {
const res = flow.parser.parse('graph TD;A-- textNoSpace --xB;');
const vert = flow.parser.yy.getVertices();
@@ -210,7 +204,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].type).toBe('arrow_cross');
});
- it('it should handle text with multiple leading space', function () {
+ it('should handle text with multiple leading space', function () {
const res = flow.parser.parse('graph TD;A-- textNoSpace --xB;');
const vert = flow.parser.yy.getVertices();
@@ -219,7 +213,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].type).toBe('arrow_cross');
});
- it('should handle with space', function () {
+ it('should handle with space', function () {
const res = flow.parser.parse('graph TD;A-- text including space --xB;');
const vert = flow.parser.yy.getVertices();
@@ -228,7 +222,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].type).toBe('arrow_cross');
});
- it('it should handle text with /', function () {
+ it('should handle text with /', function () {
const res = flow.parser.parse('graph TD;A -- text with / should work --x B;');
const vert = flow.parser.yy.getVertices();
@@ -237,7 +231,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].text).toBe('text with / should work');
});
- it('it should handle space and space between vertices and link', function () {
+ it('should handle space and space between vertices and link', function () {
const res = flow.parser.parse('graph TD;A -- textNoSpace --x B;');
const vert = flow.parser.yy.getVertices();
@@ -302,7 +296,7 @@ describe('[Text] when parsing', () => {
});
describe('it should handle text in vertices, ', function () {
- it('it should handle space', function () {
+ it('should handle space', function () {
const res = flow.parser.parse('graph TD;A-->C(Chimpansen hoppar);');
const vert = flow.parser.yy.getVertices();
@@ -311,7 +305,7 @@ describe('[Text] when parsing', () => {
expect(vert['C'].type).toBe('round');
expect(vert['C'].text).toBe('Chimpansen hoppar');
});
- it('it should handle åäö and minus', function () {
+ it('should handle åäö and minus', function () {
const res = flow.parser.parse('graph TD;A-->C{Chimpansen hoppar åäö-ÅÄÖ};');
const vert = flow.parser.yy.getVertices();
@@ -321,7 +315,7 @@ describe('[Text] when parsing', () => {
expect(vert['C'].text).toBe('Chimpansen hoppar åäö-ÅÄÖ');
});
- it('it should handle with åäö, minus and space and br', function () {
+ it('should handle with åäö, minus and space and br', function () {
const res = flow.parser.parse('graph TD;A-->C(Chimpansen hoppar åäö
- ÅÄÖ);');
const vert = flow.parser.yy.getVertices();
@@ -330,7 +324,7 @@ describe('[Text] when parsing', () => {
expect(vert['C'].type).toBe('round');
expect(vert['C'].text).toBe('Chimpansen hoppar åäö
- ÅÄÖ');
});
- // xit('it should handle åäö, minus and space and br',function(){
+ // xit('should handle åäö, minus and space and br',function(){
// const res = flow.parser.parse('graph TD; A[Object(foo,bar)]-->B(Thing);');
//
// const vert = flow.parser.yy.getVertices();
@@ -339,21 +333,21 @@ describe('[Text] when parsing', () => {
// expect(vert['C'].type).toBe('round');
// expect(vert['C'].text).toBe(' A[Object(foo,bar)]-->B(Thing);');
// });
- it('it should handle unicode chars', function () {
+ it('should handle unicode chars', function () {
const res = flow.parser.parse('graph TD;A-->C(Начало);');
const vert = flow.parser.yy.getVertices();
expect(vert['C'].text).toBe('Начало');
});
- it('it should handle backslask', function () {
+ it('should handle backslask', function () {
const res = flow.parser.parse('graph TD;A-->C(c:\\windows);');
const vert = flow.parser.yy.getVertices();
expect(vert['C'].text).toBe('c:\\windows');
});
- it('it should handle CAPS', function () {
+ it('should handle CAPS', function () {
const res = flow.parser.parse('graph TD;A-->C(some CAPS);');
const vert = flow.parser.yy.getVertices();
@@ -362,7 +356,7 @@ describe('[Text] when parsing', () => {
expect(vert['C'].type).toBe('round');
expect(vert['C'].text).toBe('some CAPS');
});
- it('it should handle directions', function () {
+ it('should handle directions', function () {
const res = flow.parser.parse('graph TD;A-->C(some URL);');
const vert = flow.parser.yy.getVertices();
diff --git a/src/diagrams/git/gitGraphParser.spec b/src/diagrams/git/gitGraphParser.spec
index 90e692d50..0a8256c5b 100644
--- a/src/diagrams/git/gitGraphParser.spec
+++ b/src/diagrams/git/gitGraphParser.spec
@@ -115,7 +115,7 @@ describe('when parsing a gitGraph', function() {
expect(parser.yy.getCurrentBranch()).toBe('master');
});
- it('it should reset a branch', function() {
+ it('should reset a branch', function() {
const str =
'gitGraph:\n' +
'commit\n' +
@@ -153,7 +153,7 @@ describe('when parsing a gitGraph', function() {
expect(parser.yy.getHead().id).toEqual(master.parent);
});
- it('it should handle fast forwardable merges', function() {
+ it('should handle fast forwardable merges', function() {
const str =
'gitGraph:\n' +
'commit\n' +
@@ -173,7 +173,7 @@ describe('when parsing a gitGraph', function() {
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']);
});
- it('it should handle cases when merge is a noop', function() {
+ it('should handle cases when merge is a noop', function() {
const str =
'gitGraph:\n' +
'commit\n' +
@@ -192,7 +192,7 @@ describe('when parsing a gitGraph', function() {
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']);
});
- it('it should handle merge with 2 parents', function() {
+ it('should handle merge with 2 parents', function() {
const str =
'gitGraph:\n' +
'commit\n' +
@@ -213,7 +213,7 @@ describe('when parsing a gitGraph', function() {
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['master']);
});
- it('it should handle ff merge when history walk has two parents (merge commit)', function() {
+ it('should handle ff merge when history walk has two parents (merge commit)', function() {
const str =
'gitGraph:\n' +
'commit\n' +
@@ -239,7 +239,7 @@ describe('when parsing a gitGraph', function() {
parser.yy.prettyPrint();
});
- it('it should generate a secure random ID for commits', function() {
+ it('should generate a secure random ID for commits', function() {
const str = 'gitGraph:\n' + 'commit\n' + 'commit\n';
const EXPECTED_LENGTH = 7;
const EXPECTED_CHARACTERS = '0123456789abcdef';
@@ -267,7 +267,7 @@ describe('when parsing a gitGraph', function() {
});
});
- it('it should generate an array of known branches', function() {
+ it('should generate an array of known branches', function() {
const str =
'gitGraph:\n' +
'commit\n' +
diff --git a/src/diagrams/sequence/sequenceDiagram.spec.js b/src/diagrams/sequence/sequenceDiagram.spec.js
index 0ee00135d..808eb567e 100644
--- a/src/diagrams/sequence/sequenceDiagram.spec.js
+++ b/src/diagrams/sequence/sequenceDiagram.spec.js
@@ -126,7 +126,7 @@ Bob-->Alice: I am good thanks!`;
expect(messages[0].from).toBe('Alice');
expect(messages[2].from).toBe('Bob');
});
- it('it should not show sequence numbers per default', function () {
+ it('should not show sequence numbers per default', function () {
const str = `
sequenceDiagram
Alice->Bob:Hello Bob, how are you?
@@ -137,7 +137,7 @@ Bob-->Alice: I am good thanks!`;
diagram.renderer.draw(str, 'tst', '1.2.3', diagram); // needs to be rendered for the correct value of visibility autonumbers
expect(diagram.db.showSequenceNumbers()).toBe(false);
});
- it('it should show sequence numbers when autonumber is enabled', function () {
+ it('should show sequence numbers when autonumber is enabled', function () {
const str = `
sequenceDiagram
autonumber
@@ -149,7 +149,7 @@ Bob-->Alice: I am good thanks!`;
diagram.renderer.draw(str, 'tst', '1.2.3', diagram); // needs to be rendered for the correct value of visibility autonumbers
expect(diagram.db.showSequenceNumbers()).toBe(true);
});
- it('it should handle a sequenceDiagram definition with a title:', function () {
+ it('should handle a sequenceDiagram definition with a title:', function () {
const str = `
sequenceDiagram
title: Diagram Title
@@ -172,7 +172,7 @@ Bob-->Alice: I am good thanks!`;
expect(title).toBe('Diagram Title');
});
- it('it should handle a sequenceDiagram definition with a title without a :', function () {
+ it('should handle a sequenceDiagram definition with a title without a :', function () {
const str = `
sequenceDiagram
title Diagram Title
@@ -195,7 +195,7 @@ Bob-->Alice: I am good thanks!`;
expect(title).toBe('Diagram Title');
});
- it('it should handle a sequenceDiagram definition with a accessibility title and description (accDescr)', function () {
+ it('should handle a sequenceDiagram definition with a accessibility title and description (accDescr)', function () {
const str = `
sequenceDiagram
title: Diagram Title
@@ -210,7 +210,7 @@ Alice->Bob:Hello Bob, how are you?
expect(diagram.db.getAccDescription()).toBe('Accessibility Description');
const messages = diagram.db.getMessages();
});
- it('it should handle a sequenceDiagram definition with a accessibility title and multiline description (accDescr)', function () {
+ it('should handle a sequenceDiagram definition with a accessibility title and multiline description (accDescr)', function () {
const str = `
sequenceDiagram
accTitle: This is the title
@@ -227,7 +227,7 @@ Alice->Bob:Hello Bob, how are you?
const messages = diagram.db.getMessages();
});
- it('it should space in actor names', function () {
+ it('should space in actor names', function () {
const str = `
sequenceDiagram
Alice->Bob:Hello Bob, how are - you?
@@ -244,7 +244,7 @@ Bob-->Alice: I am good thanks!`;
expect(messages[0].from).toBe('Alice');
expect(messages[1].from).toBe('Bob');
});
- it('it should handle dashes in actor names', function () {
+ it('should handle dashes in actor names', function () {
const str = `
sequenceDiagram
Alice-in-Wonderland->Bob:Hello Bob, how are - you?
@@ -261,7 +261,7 @@ Bob-->Alice-in-Wonderland:I am good thanks!`;
expect(messages[0].from).toBe('Alice-in-Wonderland');
expect(messages[1].from).toBe('Bob');
});
- it('it should alias participants', function () {
+ it('should alias participants', function () {
const str = `
sequenceDiagram
participant A as Alice
@@ -282,7 +282,7 @@ B-->A: I am good thanks!`;
expect(messages[0].from).toBe('A');
expect(messages[1].from).toBe('B');
});
- it('it should alias a mix of actors and participants apa12', function () {
+ it('should alias a mix of actors and participants apa12', function () {
const str = `
sequenceDiagram
actor Alice as Alice2
@@ -310,7 +310,7 @@ sequenceDiagram
expect(messages[0].from).toBe('Alice');
expect(messages[4].to).toBe('Joan');
});
- it('it should alias actors apa13', function () {
+ it('should alias actors apa13', function () {
const str = `
sequenceDiagram
actor A as Alice
@@ -330,7 +330,7 @@ B-->A: I am good thanks!`;
expect(messages[0].from).toBe('A');
expect(messages[1].from).toBe('B');
});
- it('it should handle in async messages', function () {
+ it('should handle in async messages', function () {
const str = `
sequenceDiagram
Alice-xBob:Hello Bob, how are you?`;
@@ -345,7 +345,7 @@ Alice-xBob:Hello Bob, how are you?`;
expect(messages.length).toBe(1);
expect(messages[0].type).toBe(diagram.db.LINETYPE.SOLID_CROSS);
});
- it('it should handle in async dotted messages', function () {
+ it('should handle in async dotted messages', function () {
const str = `
sequenceDiagram
Alice--xBob:Hello Bob, how are you?`;
@@ -360,7 +360,7 @@ Alice--xBob:Hello Bob, how are you?`;
expect(messages.length).toBe(1);
expect(messages[0].type).toBe(diagram.db.LINETYPE.DOTTED_CROSS);
});
- it('it should handle in sync messages', function () {
+ it('should handle in sync messages', function () {
const str = `
sequenceDiagram
Alice-)Bob:Hello Bob, how are you?`;
@@ -375,7 +375,7 @@ Alice-)Bob:Hello Bob, how are you?`;
expect(messages.length).toBe(1);
expect(messages[0].type).toBe(diagram.db.LINETYPE.SOLID_POINT);
});
- it('it should handle in sync dotted messages', function () {
+ it('should handle in sync dotted messages', function () {
const str = `
sequenceDiagram
Alice--)Bob:Hello Bob, how are you?`;
@@ -390,7 +390,7 @@ Alice--)Bob:Hello Bob, how are you?`;
expect(messages.length).toBe(1);
expect(messages[0].type).toBe(diagram.db.LINETYPE.DOTTED_POINT);
});
- it('it should handle in arrow messages', function () {
+ it('should handle in arrow messages', function () {
const str = `
sequenceDiagram
Alice->>Bob:Hello Bob, how are you?`;
@@ -405,7 +405,7 @@ Alice->>Bob:Hello Bob, how are you?`;
expect(messages.length).toBe(1);
expect(messages[0].type).toBe(diagram.db.LINETYPE.SOLID);
});
- it('it should handle in arrow messages', function () {
+ it('should handle in arrow messages', function () {
const str = 'sequenceDiagram\n' + 'Alice-->>Bob:Hello Bob, how are you?';
mermaidAPI.parse(str);
@@ -418,7 +418,7 @@ Alice->>Bob:Hello Bob, how are you?`;
expect(messages.length).toBe(1);
expect(messages[0].type).toBe(diagram.db.LINETYPE.DOTTED);
});
- it('it should handle actor activation', function () {
+ it('should handle actor activation', function () {
const str = `
sequenceDiagram
Alice-->>Bob:Hello Bob, how are you?
@@ -441,7 +441,7 @@ deactivate Bob`;
expect(messages[3].type).toBe(diagram.db.LINETYPE.ACTIVE_END);
expect(messages[3].from.actor).toBe('Bob');
});
- it('it should handle actor one line notation activation', function () {
+ it('should handle actor one line notation activation', function () {
const str = `
sequenceDiagram
Alice-->>+Bob:Hello Bob, how are you?
@@ -462,7 +462,7 @@ deactivate Bob`;
expect(messages[3].type).toBe(diagram.db.LINETYPE.ACTIVE_END);
expect(messages[3].from.actor).toBe('Bob');
});
- it('it should handle stacked activations', function () {
+ it('should handle stacked activations', function () {
const str = `
sequenceDiagram
Alice-->>+Bob:Hello Bob, how are you?
@@ -489,7 +489,7 @@ deactivate Bob`;
expect(messages[7].type).toBe(diagram.db.LINETYPE.ACTIVE_END);
expect(messages[7].from.actor).toBe('Carol');
});
- it('it should handle fail parsing when activating an inactive participant', function () {
+ it('should handle fail parsing when activating an inactive participant', function () {
const str = `
sequenceDiagram
participant user as End User
@@ -515,7 +515,7 @@ deactivate Bob`;
expect(error).toBe(true);
});
- it('it should handle comments in a sequenceDiagram', function () {
+ it('should handle comments in a sequenceDiagram', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -534,7 +534,7 @@ deactivate Bob`;
expect(messages[0].from).toBe('Alice');
expect(messages[2].from).toBe('Bob');
});
- it('it should handle new lines in a sequenceDiagram', function () {
+ it('should handle new lines in a sequenceDiagram', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -555,7 +555,7 @@ deactivate Bob`;
expect(messages[0].from).toBe('Alice');
expect(messages[2].from).toBe('Bob');
});
- it('it should handle semicolons', function () {
+ it('should handle semicolons', function () {
const str = `
sequenceDiagram;Alice->Bob: Hello Bob, how are you?;Note right of Bob: Bob thinks;Bob-->Alice: I am good thanks!;`;
@@ -570,7 +570,7 @@ sequenceDiagram;Alice->Bob: Hello Bob, how are you?;Note right of Bob: Bob think
expect(messages[0].from).toBe('Alice');
expect(messages[2].from).toBe('Bob');
});
- it('it should handle one leading space in lines in a sequenceDiagram', function () {
+ it('should handle one leading space in lines in a sequenceDiagram', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -590,7 +590,7 @@ Bob-->Alice: I am good thanks!`;
expect(messages[0].from).toBe('Alice');
expect(messages[2].from).toBe('Bob');
});
- it('it should handle several leading spaces in lines in a sequenceDiagram', function () {
+ it('should handle several leading spaces in lines in a sequenceDiagram', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -610,7 +610,7 @@ Bob-->Alice: I am good thanks!`;
expect(messages[0].from).toBe('Alice');
expect(messages[2].from).toBe('Bob');
});
- it('it should handle several leading spaces in lines in a sequenceDiagram', function () {
+ it('should handle several leading spaces in lines in a sequenceDiagram', function () {
const str = `
sequenceDiagram
participant Alice
@@ -635,7 +635,7 @@ Bob-->John: Jolly good!`;
expect(messages[0].from).toBe('Alice');
expect(messages[2].from).toBe('John');
});
- it('it should handle different line breaks', function () {
+ it('should handle different line breaks', function () {
const str = `
sequenceDiagram
participant 1 as multiline
text
@@ -670,7 +670,7 @@ note right of 1: multiline
text
expect(messages[6].message).toBe('multiline
text');
expect(messages[7].message).toBe('multiline
text');
});
- it('it should handle notes and messages without wrap specified', function () {
+ it('should handle notes and messages without wrap specified', function () {
const str = `
sequenceDiagram
participant 1
@@ -709,7 +709,7 @@ note right of 1:nowrap: multiline
text
expect(messages[6].wrap).toBe(false);
expect(messages[7].wrap).toBe(false);
});
- it('it should handle notes and messages with wrap specified', function () {
+ it('should handle notes and messages with wrap specified', function () {
const str = `
sequenceDiagram
participant 1
@@ -734,7 +734,7 @@ note right of 3:wrap: multiline
text
expect(messages[2].wrap).toBe(true);
expect(messages[3].wrap).toBe(true);
});
- it('it should handle notes and messages with nowrap or line breaks', function () {
+ it('should handle notes and messages with nowrap or line breaks', function () {
const str = `
sequenceDiagram
participant 1
@@ -751,7 +751,7 @@ note right of 2: single-line text
expect(messages[0].wrap).toBe(false);
expect(messages[1].wrap).toBe(false);
});
- it('it should handle notes over a single actor', function () {
+ it('should handle notes over a single actor', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -764,7 +764,7 @@ Note over Bob: Bob thinks
expect(messages[1].from).toBe('Bob');
expect(messages[1].to).toBe('Bob');
});
- it('it should handle notes over multiple actors', function () {
+ it('should handle notes over multiple actors', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -780,7 +780,7 @@ Note over Bob,Alice: resolution
expect(messages[2].from).toBe('Bob');
expect(messages[2].to).toBe('Alice');
});
- it('it should handle loop statements', function () {
+ it('should handle loop statements', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -803,7 +803,7 @@ end`;
expect(messages[0].from).toBe('Alice');
expect(messages[1].from).toBe('Bob');
});
- it('it should add a rect around sequence', function () {
+ it('should add a rect around sequence', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -827,7 +827,7 @@ end`;
expect(messages[4].type).toEqual(diagram.db.LINETYPE.RECT_END);
});
- it('it should allow for nested rects', function () {
+ it('should allow for nested rects', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -854,7 +854,7 @@ end`;
expect(messages[5].type).toEqual(diagram.db.LINETYPE.DOTTED_OPEN);
expect(messages[6].type).toEqual(diagram.db.LINETYPE.RECT_END);
});
- it('it should handle opt statements', function () {
+ it('should handle opt statements', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -877,7 +877,7 @@ end`;
expect(messages[0].from).toBe('Alice');
expect(messages[1].from).toBe('Bob');
});
- it('it should handle alt statements', function () {
+ it('should handle alt statements', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -903,7 +903,7 @@ end`;
expect(messages[0].from).toBe('Alice');
expect(messages[1].from).toBe('Bob');
});
- it('it should handle alt statements with multiple elses', function () {
+ it('should handle alt statements with multiple elses', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -930,7 +930,7 @@ end`;
expect(messages[7].from).toBe('Bob');
expect(messages[8].type).toBe(diagram.db.LINETYPE.ALT_END);
});
- it('it should handle critical statements without options', function () {
+ it('should handle critical statements without options', function () {
const str = `
sequenceDiagram
critical Establish a connection to the DB
@@ -950,7 +950,7 @@ sequenceDiagram
expect(messages[1].from).toBe('Service');
expect(messages[2].type).toBe(diagram.db.LINETYPE.CRITICAL_END);
});
- it('it should handle critical statements with options', function () {
+ it('should handle critical statements with options', function () {
const str = `
sequenceDiagram
critical Establish a connection to the DB
@@ -978,7 +978,7 @@ sequenceDiagram
expect(messages[5].from).toBe('Service');
expect(messages[6].type).toBe(diagram.db.LINETYPE.CRITICAL_END);
});
- it('it should handle break statements', function () {
+ it('should handle break statements', function () {
const str = `
sequenceDiagram
Consumer-->API: Book something
@@ -1004,7 +1004,7 @@ sequenceDiagram
expect(messages[4].type).toBe(diagram.db.LINETYPE.BREAK_END);
expect(messages[5].from).toBe('API');
});
- it('it should handle par statements a sequenceDiagram', function () {
+ it('should handle par statements a sequenceDiagram', function () {
const str = `
sequenceDiagram
par Parallel one
@@ -1031,7 +1031,7 @@ end`;
expect(messages[1].from).toBe('Alice');
expect(messages[2].from).toBe('Bob');
});
- it('it should handle special characters in signals', function () {
+ it('should handle special characters in signals', function () {
const str = 'sequenceDiagram\n' + 'Alice->Bob: -:<>,;# comment';
mermaidAPI.parse(str);
@@ -1039,7 +1039,7 @@ end`;
const messages = diagram.db.getMessages();
expect(messages[0].message).toBe('-:<>,');
});
- it('it should handle special characters in notes', function () {
+ it('should handle special characters in notes', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1050,7 +1050,7 @@ Note right of Bob: -:<>,;# comment`;
const messages = diagram.db.getMessages();
expect(messages[1].message).toBe('-:<>,');
});
- it('it should handle special characters in loop', function () {
+ it('should handle special characters in loop', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1063,7 +1063,7 @@ end`;
const messages = diagram.db.getMessages();
expect(messages[1].message).toBe('-:<>,');
});
- it('it should handle special characters in opt', function () {
+ it('should handle special characters in opt', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1076,7 +1076,7 @@ end`;
const messages = diagram.db.getMessages();
expect(messages[1].message).toBe('-:<>,');
});
- it('it should handle special characters in alt', function () {
+ it('should handle special characters in alt', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1092,7 +1092,7 @@ end`;
expect(messages[1].message).toBe('-:<>,');
expect(messages[3].message).toBe(',<>:-');
});
- it('it should handle special characters in par', function () {
+ it('should handle special characters in par', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1108,7 +1108,7 @@ end`;
expect(messages[1].message).toBe('-:<>,');
expect(messages[3].message).toBe(',<>:-');
});
- it('it should handle no-label loop', function () {
+ it('should handle no-label loop', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1122,7 +1122,7 @@ end`;
expect(messages[1].message).toBe('');
expect(messages[2].message).toBe('I am good thanks!');
});
- it('it should handle no-label opt', function () {
+ it('should handle no-label opt', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1136,7 +1136,7 @@ end`;
expect(messages[1].message).toBe('');
expect(messages[2].message).toBe('I am good thanks!');
});
- it('it should handle no-label alt', function () {
+ it('should handle no-label alt', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1153,7 +1153,7 @@ end`;
expect(messages[3].message).toBe('');
expect(messages[4].message).toBe('I am good thanks!');
});
- it('it should handle no-label par', function () {
+ it('should handle no-label par', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1171,7 +1171,7 @@ end`;
expect(messages[4].message).toBe('I am good thanks!');
});
- it('it should handle links', function () {
+ it('should handle links', function () {
const str = `
sequenceDiagram
participant a as Alice
@@ -1198,7 +1198,7 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com
expect(actors.a.links['Tests']).toBe('https://tests.contoso.com/?svc=alice@contoso.com');
});
- it('it should handle properties EXPERIMENTAL: USE WITH CAUTION', function () {
+ it('should handle properties EXPERIMENTAL: USE WITH CAUTION', function () {
//Be aware that the syntax for "properties" is likely to be changed.
const str = `
sequenceDiagram
@@ -1245,7 +1245,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
diagram.renderer.bounds.init();
conf = diagram.db.getConfig();
});
- it('it should handle a simple bound call', function () {
+ it('should handle a simple bound call', function () {
diagram.renderer.bounds.insert(100, 100, 200, 200);
const { bounds } = diagram.renderer.bounds.getBounds();
@@ -1254,7 +1254,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(200);
expect(bounds.stopy).toBe(200);
});
- it('it should handle an expanding bound', function () {
+ it('should handle an expanding bound', function () {
diagram.renderer.bounds.insert(100, 100, 200, 200);
diagram.renderer.bounds.insert(25, 50, 300, 400);
@@ -1264,7 +1264,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(300);
expect(bounds.stopy).toBe(400);
});
- it('it should handle inserts within the bound without changing the outer bounds', function () {
+ it('should handle inserts within the bound without changing the outer bounds', function () {
diagram.renderer.bounds.insert(100, 100, 200, 200);
diagram.renderer.bounds.insert(25, 50, 300, 400);
diagram.renderer.bounds.insert(125, 150, 150, 200);
@@ -1275,7 +1275,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(300);
expect(bounds.stopy).toBe(400);
});
- it('it should handle a loop without expanding the area', function () {
+ it('should handle a loop without expanding the area', function () {
diagram.renderer.bounds.insert(25, 50, 300, 400);
diagram.renderer.bounds.verticalPos = 150;
diagram.renderer.bounds.newLoop();
@@ -1296,7 +1296,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(300);
expect(bounds.stopy).toBe(400);
});
- it('it should handle multiple loops withtout expanding the bounds', function () {
+ it('should handle multiple loops withtout expanding the bounds', function () {
diagram.renderer.bounds.insert(100, 100, 1000, 1000);
diagram.renderer.bounds.verticalPos = 200;
diagram.renderer.bounds.newLoop();
@@ -1327,7 +1327,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(1000);
expect(bounds.stopy).toBe(1000);
});
- it('it should handle a loop that expands the area', function () {
+ it('should handle a loop that expands the area', function () {
diagram.renderer.bounds.insert(100, 100, 200, 200);
diagram.renderer.bounds.verticalPos = 200;
diagram.renderer.bounds.newLoop();
@@ -1414,7 +1414,7 @@ participant Alice`;
expect(bounds.stopy).toBe(conf.height);
});
});
- it('it should handle same actor with different whitespace properly', function () {
+ it('should handle same actor with different whitespace properly', function () {
const str = `
sequenceDiagram
participant Alice
@@ -1427,7 +1427,7 @@ participant Alice
const actors = diagram.db.getActors();
expect(Object.keys(actors)).toEqual(['Alice']);
});
- it('it should handle one actor and a centered note', function () {
+ it('should handle one actor and a centered note', function () {
const str = `
sequenceDiagram
participant Alice
@@ -1445,7 +1445,7 @@ Note over Alice: Alice thinks
// 10 comes from mock of text height
expect(bounds.stopy).toBe(models.lastNote().stopy);
});
- it('it should handle one actor and a note to the left', function () {
+ it('should handle one actor and a note to the left', function () {
const str = `
sequenceDiagram
participant Alice
@@ -1461,7 +1461,7 @@ Note left of Alice: Alice thinks`;
// 10 comes from mock of text height
expect(bounds.stopy).toBe(models.lastNote().stopy);
});
- it('it should handle one actor and a note to the right', function () {
+ it('should handle one actor and a note to the right', function () {
const str = `
sequenceDiagram
participant Alice
@@ -1477,7 +1477,7 @@ Note right of Alice: Alice thinks`;
// 10 comes from mock of text height
expect(bounds.stopy).toBe(models.lastNote().stopy);
});
- it('it should handle two actors', function () {
+ it('should handle two actors', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?`;
@@ -1491,7 +1491,7 @@ Alice->Bob: Hello Bob, how are you?`;
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
});
- it('it should handle two actors with init directive', function () {
+ it('should handle two actors with init directive', function () {
const str = `
%%{init: {'logLevel': 0}}%%
sequenceDiagram
@@ -1508,7 +1508,7 @@ Alice->Bob: Hello Bob, how are you?`;
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
});
- it('it should handle two actors with init directive with multiline directive', function () {
+ it('should handle two actors with init directive with multiline directive', function () {
const str = `
%%{init: { 'logLevel': 0}}%%
sequenceDiagram
@@ -1530,7 +1530,7 @@ Alice->Bob: Hello Bob, how are you?`;
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
expect(msgs.every((v) => v.wrap)).toBe(true);
});
- it('it should handle two actors and two centered shared notes', function () {
+ it('should handle two actors and two centered shared notes', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1547,7 +1547,7 @@ Note over Bob,Alice: Looks back
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastNote().stopy);
});
- it('it should draw two actors and two messages', function () {
+ it('should draw two actors and two messages', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1562,7 +1562,7 @@ Bob->Alice: Fine!`;
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
});
- it('it should draw two actors notes to the right', function () {
+ it('should draw two actors notes to the right', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1581,7 +1581,7 @@ Bob->Alice: Fine!`;
expect(bounds.stopx).toBe(expStopX);
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
});
- it('it should draw two actors notes to the left', function () {
+ it('should draw two actors notes to the left', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1598,7 +1598,7 @@ Bob->Alice: Fine!`;
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
});
- it('it should draw two actors notes to the left with text wrapped (inline)', function () {
+ it('should draw two actors notes to the left with text wrapped (inline)', function () {
const str = `
sequenceDiagram
Alice->>Bob:wrap: Hello Bob, how are you? If you are not available right now, I can leave you a message. Please get back to me as soon as you can!
@@ -1617,7 +1617,7 @@ Bob->>Alice: Fine!`;
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
});
- it('it should draw two actors notes to the left with text wrapped (directive)', function () {
+ it('should draw two actors notes to the left with text wrapped (directive)', function () {
const str = `
%%{init: { 'theme': 'dark' } }%%
sequenceDiagram
@@ -1640,7 +1640,7 @@ Bob->>Alice: Fine!`;
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
});
- it('it should draw two actors notes to the left with text wrapped and the init directive sets the theme to dark', function () {
+ it('should draw two actors notes to the left with text wrapped and the init directive sets the theme to dark', function () {
const str = `
%%{init:{'theme':'dark'}}%%
sequenceDiagram
@@ -1663,7 +1663,7 @@ Bob->>Alice: Fine!`;
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
});
- it('it should draw two actors, notes to the left with text wrapped and the init directive sets the theme to dark and fontFamily to Menlo, fontSize to 18, and fontWeight to 800', function () {
+ it('should draw two actors, notes to the left with text wrapped and the init directive sets the theme to dark and fontFamily to Menlo, fontSize to 18, and fontWeight to 800', function () {
const str = `
%%{init: { "theme": "dark", 'config': { "fontFamily": "Menlo", "fontSize": 18, "messageFontWeight": 400, "wrap": true }}}%%
sequenceDiagram
@@ -1688,7 +1688,7 @@ Bob->>Alice: Fine!`;
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastMessage().stopy + 10);
});
- it('it should draw two loops', function () {
+ it('should draw two loops', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
@@ -1705,7 +1705,7 @@ end`;
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin);
expect(bounds.stopy).toBe(models.lastLoop().stopy);
});
- it('it should draw background rect', function () {
+ it('should draw background rect', function () {
const str = `
sequenceDiagram
Alice->Bob: Hello Bob, are you alright?
@@ -1755,7 +1755,7 @@ describe('when rendering a sequenceDiagram with actor mirror activated', functio
diagram.renderer.bounds.init();
});
['tspan', 'fo', 'old', undefined].forEach(function (textPlacement) {
- it('it should handle one actor, when textPlacement is' + textPlacement, function () {
+ it('should handle one actor, when textPlacement is' + textPlacement, function () {
mermaidAPI.initialize(addConf(conf, 'textPlacement', textPlacement));
diagram.renderer.bounds.init();
const str = `
@@ -1799,7 +1799,7 @@ describe('when rendering a sequenceDiagram with directives', function () {
diagram.renderer.bounds.init();
});
- it('it should handle one actor, when theme is dark and logLevel is 1 DX1', function () {
+ it('should handle one actor, when theme is dark and logLevel is 1 DX1', function () {
const str = `
%%{init: { "theme": "dark", "logLevel": 1 } }%%
sequenceDiagram
@@ -1823,7 +1823,7 @@ participant Alice
models.lastActor().y + models.lastActor().height + mermaid.sequence.boxMargin
);
});
- it('it should handle one actor, when logLevel is 3', function () {
+ it('should handle one actor, when logLevel is 3', function () {
const str = `
%%{initialize: { "logLevel": 3 }}%%
sequenceDiagram
@@ -1843,7 +1843,7 @@ participant Alice
models.lastActor().y + models.lastActor().height + mermaid.sequence.boxMargin
);
});
- it('it should hide sequence numbers when autonumber is removed when autonumber is enabled', function () {
+ it('should hide sequence numbers when autonumber is removed when autonumber is enabled', function () {
const str1 = `
sequenceDiagram
autonumber
diff --git a/src/diagrams/sequence/svgDraw.spec.js b/src/diagrams/sequence/svgDraw.spec.js
index b9e7ced4a..14dd9a202 100644
--- a/src/diagrams/sequence/svgDraw.spec.js
+++ b/src/diagrams/sequence/svgDraw.spec.js
@@ -3,7 +3,7 @@ const { MockD3 } = require('d3');
describe('svgDraw', function () {
describe('drawRect', function () {
- it('it should append a rectangle', function () {
+ it('should append a rectangle', function () {
const svg = MockD3('svg');
svgDraw.drawRect(svg, {
x: 10,
@@ -29,7 +29,7 @@ describe('svgDraw', function () {
expect(rect.attr).toHaveBeenCalledWith('ry', '10');
expect(rect.attr).toHaveBeenCalledWith('class', 'unitTestRectangleClass');
});
- it('it should not add the class attribute if a class isn`t provided', () => {
+ it('should not add the class attribute if a class isn`t provided', () => {
const svg = MockD3('svg');
svgDraw.drawRect(svg, {
x: 10,
@@ -49,7 +49,7 @@ describe('svgDraw', function () {
});
});
describe('drawText', function () {
- it('it should append a single element', function () {
+ it('should append a single element', function () {
const svg = MockD3('svg');
svgDraw.drawText(svg, {
x: 10,
@@ -73,7 +73,7 @@ describe('svgDraw', function () {
expect(text.style).toHaveBeenCalledWith('font-size', '10px');
expect(text.style).toHaveBeenCalledWith('font-weight', '500');
});
- it('it should append a multiple elements', function () {
+ it('should append a multiple elements', function () {
const svg = MockD3('svg');
svgDraw.drawText(svg, {
x: 10,
@@ -101,7 +101,7 @@ describe('svgDraw', function () {
});
});
describe('drawBackgroundRect', function () {
- it('it should append a rect before the previous element within a given bound', function () {
+ it('should append a rect before the previous element within a given bound', function () {
const svg = MockD3('svg');
const boundingRect = {
startx: 50,
@@ -125,12 +125,12 @@ describe('svgDraw', function () {
});
});
describe('sanitizeUrl', function () {
- it('it should sanitize malicious urls', function () {
+ it('should sanitize malicious urls', function () {
const maliciousStr = 'javascript:script:alert(1)';
const result = svgDraw.sanitizeUrl(maliciousStr);
expect(result).not.toContain('javascript:alert(1)');
});
- it('it should not sanitize non dangerous urls', function () {
+ it('should not sanitize non dangerous urls', function () {
const maliciousStr = 'javajavascript:script:alert(1)';
const result = svgDraw.sanitizeUrl(maliciousStr);
expect(result).not.toContain('javascript:alert(1)');
diff --git a/src/diagrams/user-journey/parser/journey.spec.js b/src/diagrams/user-journey/parser/journey.spec.js
index 2454c1d16..cc54d9f78 100644
--- a/src/diagrams/user-journey/parser/journey.spec.js
+++ b/src/diagrams/user-journey/parser/journey.spec.js
@@ -19,7 +19,7 @@ describe('when parsing a journey diagram it', function () {
expect(parserFnConstructor(str)).not.toThrow();
});
- it('it should handle an accessibility description (accDescr)', function () {
+ it('should handle an accessibility description (accDescr)', function () {
const str =
'journey\n' +
'accDescr: A user journey for family shopping\n' +
@@ -28,7 +28,7 @@ describe('when parsing a journey diagram it', function () {
expect(parserFnConstructor(str)).not.toThrow();
});
- it('it should handle an accessibility multiline description (accDescr)', function () {
+ it('should handle an accessibility multiline description (accDescr)', function () {
const str =
'journey\n' +
`accDescr {
@@ -44,7 +44,7 @@ describe('when parsing a journey diagram it', function () {
expect(journeyDb.getDiagramTitle()).toBe('Adding journey diagram functionality to mermaid');
expect(journeyDb.getAccTitle()).toBe('Adding acc journey diagram functionality to mermaid');
});
- it('it should handle an accessibility title (accDescr)', function () {
+ it('should handle an accessibility title (accDescr)', function () {
const str = `journey
accTitle: The title
section Order from website`;
diff --git a/src/mermaid.spec.js b/src/mermaid.spec.js
index 1c5850511..60b67ad23 100644
--- a/src/mermaid.spec.js
+++ b/src/mermaid.spec.js
@@ -46,7 +46,7 @@ describe('when using mermaid and ', function () {
flowDb.clear();
flowDb.setGen('gen-2');
});
- it('it should handle edges with text', function () {
+ it('should handle edges with text', function () {
const diag = new Diagram('graph TD;A-->|text ex|B;');
diag.db.getVertices();
const edges = diag.db.getEdges();
@@ -189,18 +189,18 @@ describe('when using mermaid and ', function () {
flowDb.clear();
flowDb.setGen('gen-2');
});
- it('it should throw for an invalid definition', function () {
+ it('should throw for an invalid definition', function () {
expect(() => mermaid.parse('this is not a mermaid diagram definition')).toThrow();
});
- it('it should not throw for a valid flow definition', function () {
+ it('should not throw for a valid flow definition', function () {
expect(() => mermaid.parse('graph TD;A--x|text including URL space|B;')).not.toThrow();
});
- it('it should throw for an invalid flow definition', function () {
+ it('should throw for an invalid flow definition', function () {
expect(() => mermaid.parse('graph TQ;A--x|text including URL space|B;')).toThrow();
});
- it('it should not throw for a valid sequenceDiagram definition', function () {
+ it('should not throw for a valid sequenceDiagram definition', function () {
const text =
'sequenceDiagram\n' +
'Alice->Bob: Hello Bob, how are you?\n\n' +
@@ -214,7 +214,7 @@ describe('when using mermaid and ', function () {
expect(() => mermaid.parse(text)).not.toThrow();
});
- it('it should throw for an invalid sequenceDiagram definition', function () {
+ it('should throw for an invalid sequenceDiagram definition', function () {
const text =
'sequenceDiagram\n' +
'Alice:->Bob: Hello Bob, how are you?\n\n' +
diff --git a/src/mermaidAPI.spec.js b/src/mermaidAPI.spec.js
index 17e139412..3c4a28ca9 100644
--- a/src/mermaidAPI.spec.js
+++ b/src/mermaidAPI.spec.js
@@ -125,11 +125,11 @@ describe('when using mermaidAPI and ', function () {
});
describe('test mermaidApi.parse() for checking validity of input ', function () {
mermaid.parseError = undefined; // ensure it parseError undefined
- it('it should throw for an invalid definition (with no mermaid.parseError() defined)', function () {
+ it('should throw for an invalid definition (with no mermaid.parseError() defined)', function () {
expect(mermaid.parseError).toEqual(undefined);
expect(() => mermaidAPI.parse('this is not a mermaid diagram definition')).toThrow();
});
- it('it should not throw for a valid definition', function () {
+ it('should not throw for a valid definition', function () {
expect(() => mermaidAPI.parse('graph TD;A--x|text including URL space|B;')).not.toThrow();
});
it('it should return false for invalid definition WITH a parseError() callback defined', function () {
@@ -142,7 +142,7 @@ describe('when using mermaidAPI and ', function () {
).toEqual(false);
expect(parseErrorWasCalled).toEqual(true);
});
- it('it should return true for valid definition', function () {
+ it('should return true for valid definition', function () {
expect(mermaidAPI.parse('graph TD;A--x|text including URL space|B;')).toEqual(true);
});
});
diff --git a/src/mermaidAPI.ts b/src/mermaidAPI.ts
index 040b861dc..8ca4a9bab 100644
--- a/src/mermaidAPI.ts
+++ b/src/mermaidAPI.ts
@@ -108,7 +108,7 @@ export const decodeEntities = function (text: string): string {
* @param {(svgCode: string, bindFunctions?: (element: Element) => void) => void} cb Callback which
* is called after rendering is finished with the svg code as inparam.
* @param {Element} container Selector to element in which a div with the graph temporarily will be
- * inserted. In one is provided a hidden div will be inserted in the body of the page instead. The
+ * inserted. If one is provided a hidden div will be inserted in the body of the page instead. The
* element will be removed when rendering is completed.
* @returns {void}
*/
diff --git a/yarn.lock b/yarn.lock
index d3b402ea5..5a85c72e6 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5469,9 +5469,9 @@ eslint-plugin-html@^7.1.0:
htmlparser2 "^8.0.1"
eslint-plugin-jest@^26.0.0:
- version "26.8.2"
- resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.8.2.tgz#42a1248a5ade2bc589eb0f9c4e0608dd89b18cf3"
- integrity sha512-67oh0FKaku9y48OpLzL3uK9ckrgLb83Sp5gxxTbtOGDw9lq6D8jw/Psj/9CipkbK406I2M7mvx1q+pv/MdbvxA==
+ version "26.8.7"
+ resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.8.7.tgz#f38f067d0a69483d64578eb43508ca7b29c8a4b7"
+ integrity sha512-nJJVv3VY6ZZvJGDMC8h1jN/TIGT4We1JkNn1lvstPURicr/eZPVnlFULQ4W2qL9ByCuCr1hPmlBOc2aZ1ktw4Q==
dependencies:
"@typescript-eslint/utils" "^5.10.0"
@@ -11128,9 +11128,9 @@ terminal-link@^2.0.0:
supports-hyperlinks "^2.0.0"
terser-webpack-plugin@^5.1.3, terser-webpack-plugin@^5.2.4:
- version "5.3.4"
- resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.4.tgz#f4d31e265883d20fda3ca9c0fc6a53f173ae62e3"
- integrity sha512-SmnkUhBxLDcBfTIeaq+ZqJXLVEyXxSaNcCeSezECdKjfkMrTTnPvapBILylYwyEvHFZAn2cJ8dtiXel5XnfOfQ==
+ version "5.3.5"
+ resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.5.tgz#f7d82286031f915a4f8fb81af4bd35d2e3c011bc"
+ integrity sha512-AOEDLDxD2zylUGf/wxHxklEkOe2/r+seuyOWujejFrIxHf11brA1/dWQNIgXa1c6/Wkxgu7zvv0JhOWfc2ELEA==
dependencies:
"@jridgewell/trace-mapping" "^0.3.14"
jest-worker "^27.4.5"