mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
fix(katex): updated specs
This commit is contained in:
parent
8b42302f9b
commit
fe8474f6c0
@ -15,7 +15,7 @@ describe('when using mermaid and ', function () {
|
||||
flowDb.clear();
|
||||
flowDb.setGen('gen-2');
|
||||
});
|
||||
it('should handle edges with text', () => {
|
||||
it('should handle edges with text', async () => {
|
||||
parser.parse('graph TD;A-->|text ex|B;');
|
||||
flowDb.getVertices();
|
||||
const edges = flowDb.getEdges();
|
||||
@ -29,7 +29,7 @@ describe('when using mermaid and ', function () {
|
||||
},
|
||||
};
|
||||
|
||||
flowRenderer.addEdges(edges, mockG, diag);
|
||||
await flowRenderer.addEdges(edges, mockG, diag);
|
||||
});
|
||||
|
||||
it('should handle edges without text', async function () {
|
||||
@ -45,10 +45,10 @@ describe('when using mermaid and ', function () {
|
||||
},
|
||||
};
|
||||
|
||||
flowRenderer.addEdges(edges, mockG, diag);
|
||||
await flowRenderer.addEdges(edges, mockG, diag);
|
||||
});
|
||||
|
||||
it('should handle open-ended edges', () => {
|
||||
it('should handle open-ended edges', async () => {
|
||||
parser.parse('graph TD;A---B;');
|
||||
flowDb.getVertices();
|
||||
const edges = flowDb.getEdges();
|
||||
@ -61,10 +61,10 @@ describe('when using mermaid and ', function () {
|
||||
},
|
||||
};
|
||||
|
||||
flowRenderer.addEdges(edges, mockG, diag);
|
||||
await flowRenderer.addEdges(edges, mockG, diag);
|
||||
});
|
||||
|
||||
it('should handle edges with styles defined', () => {
|
||||
it('should handle edges with styles defined', async () => {
|
||||
parser.parse('graph TD;A---B; linkStyle 0 stroke:val1,stroke-width:val2;');
|
||||
flowDb.getVertices();
|
||||
const edges = flowDb.getEdges();
|
||||
@ -78,9 +78,9 @@ describe('when using mermaid and ', function () {
|
||||
},
|
||||
};
|
||||
|
||||
flowRenderer.addEdges(edges, mockG, diag);
|
||||
await flowRenderer.addEdges(edges, mockG, diag);
|
||||
});
|
||||
it('should handle edges with interpolation defined', () => {
|
||||
it('should handle edges with interpolation defined', async () => {
|
||||
parser.parse('graph TD;A---B; linkStyle 0 interpolate basis');
|
||||
flowDb.getVertices();
|
||||
const edges = flowDb.getEdges();
|
||||
@ -94,9 +94,9 @@ describe('when using mermaid and ', function () {
|
||||
},
|
||||
};
|
||||
|
||||
flowRenderer.addEdges(edges, mockG, diag);
|
||||
await flowRenderer.addEdges(edges, mockG, diag);
|
||||
});
|
||||
it('should handle edges with text and styles defined', () => {
|
||||
it('should handle edges with text and styles defined', async () => {
|
||||
parser.parse('graph TD;A---|the text|B; linkStyle 0 stroke:val1,stroke-width:val2;');
|
||||
flowDb.getVertices();
|
||||
const edges = flowDb.getEdges();
|
||||
@ -111,10 +111,10 @@ describe('when using mermaid and ', function () {
|
||||
},
|
||||
};
|
||||
|
||||
flowRenderer.addEdges(edges, mockG, diag);
|
||||
await flowRenderer.addEdges(edges, mockG, diag);
|
||||
});
|
||||
|
||||
it('should set fill to "none" by default when handling edges', () => {
|
||||
it('should set fill to "none" by default when handling edges', async () => {
|
||||
parser.parse('graph TD;A---B; linkStyle 0 stroke:val1,stroke-width:val2;');
|
||||
flowDb.getVertices();
|
||||
const edges = flowDb.getEdges();
|
||||
@ -128,10 +128,10 @@ describe('when using mermaid and ', function () {
|
||||
},
|
||||
};
|
||||
|
||||
flowRenderer.addEdges(edges, mockG, diag);
|
||||
await flowRenderer.addEdges(edges, mockG, diag);
|
||||
});
|
||||
|
||||
it('should not set fill to none if fill is set in linkStyle', () => {
|
||||
it('should not set fill to none if fill is set in linkStyle', async () => {
|
||||
parser.parse('graph TD;A---B; linkStyle 0 stroke:val1,stroke-width:val2,fill:blue;');
|
||||
flowDb.getVertices();
|
||||
const edges = flowDb.getEdges();
|
||||
@ -144,7 +144,7 @@ describe('when using mermaid and ', function () {
|
||||
},
|
||||
};
|
||||
|
||||
flowRenderer.addEdges(edges, mockG, diag);
|
||||
await flowRenderer.addEdges(edges, mockG, diag);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ describe('the flowchart renderer', function () {
|
||||
['cylinder', 'cylinder'],
|
||||
['group', 'rect'],
|
||||
].forEach(function ([type, expectedShape, expectedRadios = 0]) {
|
||||
it(`should add the correct shaped node to the graph for vertex type ${type}`, function () {
|
||||
it(`should add the correct shaped node to the graph for vertex type ${type}`, async function () {
|
||||
const fakeDiag = {
|
||||
db: {
|
||||
lookUpDomId: () => {
|
||||
@ -41,7 +41,7 @@ describe('the flowchart renderer', function () {
|
||||
addedNodes.push([id, object]);
|
||||
},
|
||||
};
|
||||
addVertices(
|
||||
await addVertices(
|
||||
{
|
||||
v1: {
|
||||
type,
|
||||
@ -70,7 +70,7 @@ describe('the flowchart renderer', function () {
|
||||
['Multi<br>Line', 'Multi<br/>Line', 'Multi<br />Line', 'Multi<br\t/>Line'].forEach(function (
|
||||
labelText
|
||||
) {
|
||||
it('should handle multiline texts with different line breaks', function () {
|
||||
it('should handle multiline texts with different line breaks', async function () {
|
||||
const addedNodes = [];
|
||||
const fakeDiag = {
|
||||
db: {
|
||||
@ -84,7 +84,7 @@ describe('the flowchart renderer', function () {
|
||||
addedNodes.push([id, object]);
|
||||
},
|
||||
};
|
||||
addVertices(
|
||||
await addVertices(
|
||||
{
|
||||
v1: {
|
||||
type: 'rect',
|
||||
@ -121,7 +121,7 @@ describe('the flowchart renderer', function () {
|
||||
'color:#ccc;text-align:center;',
|
||||
],
|
||||
].forEach(function ([style, expectedStyle, expectedLabelStyle]) {
|
||||
it(`should add the styles to style and/or labelStyle for style ${style}`, function () {
|
||||
it(`should add the styles to style and/or labelStyle for style ${style}`, async function () {
|
||||
const addedNodes = [];
|
||||
const fakeDiag = {
|
||||
db: {
|
||||
@ -135,7 +135,7 @@ describe('the flowchart renderer', function () {
|
||||
addedNodes.push([id, object]);
|
||||
},
|
||||
};
|
||||
addVertices(
|
||||
await addVertices(
|
||||
{
|
||||
v1: {
|
||||
type: 'rect',
|
||||
@ -160,7 +160,7 @@ describe('the flowchart renderer', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should add default class to all nodes which do not have another class assigned`, function () {
|
||||
it(`should add default class to all nodes which do not have another class assigned`, async function () {
|
||||
const addedNodes = [];
|
||||
const mockG = {
|
||||
setNode: function (id, object) {
|
||||
@ -174,7 +174,7 @@ describe('the flowchart renderer', function () {
|
||||
},
|
||||
},
|
||||
};
|
||||
addVertices(
|
||||
await addVertices(
|
||||
{
|
||||
v1: {
|
||||
type: 'rect',
|
||||
@ -206,7 +206,7 @@ describe('the flowchart renderer', function () {
|
||||
});
|
||||
|
||||
describe('when adding edges to a graph', function () {
|
||||
it('should handle multiline texts and set centered label position', function () {
|
||||
it('should handle multiline texts and set centered label position', async function () {
|
||||
const addedEdges = [];
|
||||
const fakeDiag = {
|
||||
db: {
|
||||
@ -220,7 +220,7 @@ describe('the flowchart renderer', function () {
|
||||
addedEdges.push(data);
|
||||
},
|
||||
};
|
||||
addEdges(
|
||||
await addEdges(
|
||||
[
|
||||
{ text: 'Multi<br>Line' },
|
||||
{ text: 'Multi<br/>Line' },
|
||||
@ -251,7 +251,7 @@ describe('the flowchart renderer', function () {
|
||||
'fill:red;',
|
||||
],
|
||||
].forEach(function ([style, expectedStyle, expectedLabelStyle]) {
|
||||
it(`should add the styles to style and/or labelStyle for style ${style}`, function () {
|
||||
it(`should add the styles to style and/or labelStyle for style ${style}`, async function () {
|
||||
const addedEdges = [];
|
||||
const fakeDiag = {
|
||||
db: {
|
||||
@ -265,7 +265,7 @@ describe('the flowchart renderer', function () {
|
||||
addedEdges.push(data);
|
||||
},
|
||||
};
|
||||
addEdges([{ style: style, text: 'styling' }], mockG, fakeDiag);
|
||||
await addEdges([{ style: style, text: 'styling' }], mockG, fakeDiag);
|
||||
|
||||
expect(addedEdges).toHaveLength(1);
|
||||
expect(addedEdges[0]).toHaveProperty('style', expectedStyle);
|
||||
|
@ -207,7 +207,7 @@ Note right of Bob: Bob thinks
|
||||
Bob-->Alice: I am good thanks!`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram); // needs to be rendered for the correct value of visibility auto numbers
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram); // needs to be rendered for the correct value of visibility auto numbers
|
||||
expect(diagram.db.showSequenceNumbers()).toBe(false);
|
||||
});
|
||||
it('should show sequence numbers when autonumber is enabled', async () => {
|
||||
@ -219,7 +219,7 @@ Note right of Bob: Bob thinks
|
||||
Bob-->Alice: I am good thanks!`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram); // needs to be rendered for the correct value of visibility auto numbers
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram); // needs to be rendered for the correct value of visibility auto numbers
|
||||
expect(diagram.db.showSequenceNumbers()).toBe(true);
|
||||
});
|
||||
it('should handle a sequenceDiagram definition with a title:', async () => {
|
||||
@ -1591,7 +1591,7 @@ participant Alice`;
|
||||
// mermaidAPI.reinitialize({ sequence: { textPlacement: textPlacement } });
|
||||
await mermaidAPI.parse(str);
|
||||
// diagram.renderer.setConf(mermaidAPI.getConfig().sequence);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -1622,7 +1622,7 @@ Note over Alice: Alice thinks
|
||||
|
||||
expect(mermaidAPI.getConfig().sequence.mirrorActors).toBeFalsy();
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -1638,7 +1638,7 @@ participant Alice
|
||||
Note left of Alice: Alice thinks`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(-(conf.width / 2) - conf.actorMargin / 2);
|
||||
@ -1654,7 +1654,7 @@ participant Alice
|
||||
Note right of Alice: Alice thinks`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -1669,7 +1669,7 @@ sequenceDiagram
|
||||
Alice->Bob: Hello Bob, how are you?`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -1687,7 +1687,7 @@ end
|
||||
Alice->Bob: Hello Bob, how are you?`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -1702,7 +1702,7 @@ sequenceDiagram
|
||||
Alice->Bob: Hello Bob, how are you?`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
const mermaid = mermaidAPI.getConfig();
|
||||
@ -1722,7 +1722,7 @@ wrap
|
||||
Alice->Bob: Hello Bob, how are you?`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const msgs = diagram.db.getMessages();
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
@ -1743,7 +1743,7 @@ Note over Bob,Alice: Looks back
|
||||
`;
|
||||
// mermaidAPI.initialize({logLevel:0})
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -1758,7 +1758,7 @@ Alice->Bob: Hello Bob, how are you?
|
||||
Bob->Alice: Fine!`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -1774,7 +1774,7 @@ Note right of Bob: Bob thinks
|
||||
Bob->Alice: Fine!`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -1793,7 +1793,7 @@ Note left of Alice: Bob thinks
|
||||
Bob->Alice: Fine!`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(-(conf.width / 2) - conf.actorMargin / 2);
|
||||
@ -1810,7 +1810,7 @@ Note left of Alice: Bob thinks
|
||||
Bob->>Alice: Fine!`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
const msgs = diagram.db.getMessages();
|
||||
@ -1831,7 +1831,7 @@ Note left of Alice: Bob thinks
|
||||
Bob->>Alice: Fine!`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
const msgs = diagram.db.getMessages();
|
||||
@ -1854,7 +1854,7 @@ Note left of Alice: Bob thinks
|
||||
Bob->>Alice: Fine!`;
|
||||
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
const msgs = diagram.db.getMessages();
|
||||
@ -1876,7 +1876,7 @@ Note left of Alice: Bob thinks
|
||||
Bob->>Alice: Fine!`;
|
||||
// mermaidAPI.initialize({ logLevel: 0 });
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
const msgs = diagram.db.getMessages();
|
||||
@ -1900,7 +1900,7 @@ loop Cheers
|
||||
Bob->Alice: Fine!
|
||||
end`;
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -1918,7 +1918,7 @@ end`;
|
||||
end
|
||||
`;
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
expect(bounds.starty).toBe(0);
|
||||
@ -1967,7 +1967,7 @@ sequenceDiagram
|
||||
participant Alice`;
|
||||
diagram.renderer.bounds.init();
|
||||
await mermaidAPI.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
expect(bounds.startx).toBe(0);
|
||||
@ -2015,7 +2015,7 @@ participant Alice
|
||||
diagram.renderer.bounds.init();
|
||||
await mermaidAPI.parse(str);
|
||||
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
const mermaid = mermaidAPI.getConfig();
|
||||
@ -2036,7 +2036,7 @@ participant Alice
|
||||
`;
|
||||
|
||||
diagram.parse(str);
|
||||
diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram);
|
||||
|
||||
const { bounds, models } = diagram.renderer.bounds.getBounds();
|
||||
const mermaid = mermaidAPI.getConfig();
|
||||
@ -2057,7 +2057,7 @@ Note right of Bob: Bob thinks
|
||||
Bob-->Alice: I am good thanks!`;
|
||||
|
||||
await mermaidAPI.parse(str1);
|
||||
diagram.renderer.draw(str1, 'tst', '1.2.3', diagram); // needs to be rendered for the correct value of visibility auto numbers
|
||||
await diagram.renderer.draw(str1, 'tst', '1.2.3', diagram); // needs to be rendered for the correct value of visibility auto numbers
|
||||
expect(diagram.db.showSequenceNumbers()).toBe(true);
|
||||
|
||||
const str2 = `
|
||||
@ -2067,7 +2067,7 @@ Note right of Bob: Bob thinks
|
||||
Bob-->Alice: I am good thanks!`;
|
||||
|
||||
await mermaidAPI.parse(str2);
|
||||
diagram.renderer.draw(str2, 'tst', '1.2.3', diagram);
|
||||
await diagram.renderer.draw(str2, 'tst', '1.2.3', diagram);
|
||||
expect(diagram.db.showSequenceNumbers()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user