mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-16 18:54:12 +01:00
Grammatical touch-ups
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)');
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
@@ -174,7 +174,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 +182,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 +190,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 +201,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 +210,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 +219,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 +228,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 +237,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 +302,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 +311,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 +321,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 åäö <br> - ÅÄÖ);');
|
||||
|
||||
const vert = flow.parser.yy.getVertices();
|
||||
@@ -330,7 +330,7 @@ describe('[Text] when parsing', () => {
|
||||
expect(vert['C'].type).toBe('round');
|
||||
expect(vert['C'].text).toBe('Chimpansen hoppar åäö <br> - ÅÄÖ');
|
||||
});
|
||||
// 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 +339,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 +362,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();
|
||||
|
||||
@@ -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' +
|
||||
|
||||
@@ -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<br>text
|
||||
@@ -670,7 +670,7 @@ note right of 1: multiline<br \t/>text
|
||||
expect(messages[6].message).toBe('multiline<br \t/>text');
|
||||
expect(messages[7].message).toBe('multiline<br \t/>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<br/>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<br/>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
|
||||
|
||||
@@ -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)');
|
||||
|
||||
@@ -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`;
|
||||
|
||||
@@ -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' +
|
||||
|
||||
@@ -122,14 +122,14 @@ 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 () {
|
||||
it('should return false for invalid definition WITH a parseError() callback defined', function () {
|
||||
var parseErrorWasCalled = false;
|
||||
// also test setParseErrorHandler() call working to set mermaid.parseError
|
||||
mermaid.setParseErrorHandler(function (error, hash) {
|
||||
@@ -140,7 +140,7 @@ describe('when using mermaidAPI and ', function () {
|
||||
expect(mermaidAPI.parse('this is not a mermaid diagram definition')).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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user