mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-12 20:09:46 +02:00
Added tests for Per Link Curve Styling
This commit is contained in:
@@ -125,4 +125,43 @@ describe('flow db getData', () => {
|
|||||||
const { edges } = flowDb.getData();
|
const { edges } = flowDb.getData();
|
||||||
expect(edges[0].curve).toBe('basis');
|
expect(edges[0].curve).toBe('basis');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should support modifying interpolate using edge id syntax', () => {
|
||||||
|
flowDb.addVertex('A', { text: 'A', type: 'text' }, undefined, [], [], '', {}, undefined);
|
||||||
|
flowDb.addVertex('B', { text: 'B', type: 'text' }, undefined, [], [], '', {}, undefined);
|
||||||
|
flowDb.addVertex('C', { text: 'C', type: 'text' }, undefined, [], [], '', {}, undefined);
|
||||||
|
flowDb.addVertex('D', { text: 'D', type: 'text' }, undefined, [], [], '', {}, undefined);
|
||||||
|
flowDb.addLink(['A'], ['B'], {});
|
||||||
|
flowDb.addLink(['A'], ['C'], { id: 'e2' });
|
||||||
|
flowDb.addLink(['B'], ['D'], { id: 'e3' });
|
||||||
|
flowDb.addLink(['C'], ['D'], {});
|
||||||
|
flowDb.updateLinkInterpolate(['default'], 'stepBefore');
|
||||||
|
flowDb.updateLinkInterpolate([0], 'basis');
|
||||||
|
flowDb.addVertex(
|
||||||
|
'e2',
|
||||||
|
{ text: 'Shouldnt be used', type: 'text' },
|
||||||
|
undefined,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
'',
|
||||||
|
{},
|
||||||
|
' curve: monotoneX '
|
||||||
|
);
|
||||||
|
flowDb.addVertex(
|
||||||
|
'e3',
|
||||||
|
{ text: 'Shouldnt be used', type: 'text' },
|
||||||
|
undefined,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
'',
|
||||||
|
{},
|
||||||
|
' curve: catmullRom '
|
||||||
|
);
|
||||||
|
|
||||||
|
const { edges } = flowDb.getData();
|
||||||
|
expect(edges[0].curve).toBe('basis');
|
||||||
|
expect(edges[1].curve).toBe('monotoneX');
|
||||||
|
expect(edges[2].curve).toBe('catmullRom');
|
||||||
|
expect(edges[3].curve).toBe('stepBefore');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -37,6 +37,59 @@ describe('[Lines] when parsing', () => {
|
|||||||
expect(edges[1].interpolate).toBe('cardinal');
|
expect(edges[1].interpolate).toBe('cardinal');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle edge curve properties using edge ID', function () {
|
||||||
|
const res = flow.parser.parse(
|
||||||
|
'graph TD\n' +
|
||||||
|
'A e1@-->B\n' +
|
||||||
|
'A uniqueName@-->C\n' +
|
||||||
|
'e1@{curve: basis}\n' +
|
||||||
|
'uniqueName@{curve: cardinal}'
|
||||||
|
);
|
||||||
|
|
||||||
|
const vert = flow.parser.yy.getVertices();
|
||||||
|
const edges = flow.parser.yy.getEdges();
|
||||||
|
|
||||||
|
expect(edges[0].interpolate).toBe('basis');
|
||||||
|
expect(edges[1].interpolate).toBe('cardinal');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle edge curve properties using edge ID but without overriding default', function () {
|
||||||
|
const res = flow.parser.parse(
|
||||||
|
'graph TD\n' +
|
||||||
|
'A e1@-->B\n' +
|
||||||
|
'A-->C\n' +
|
||||||
|
'linkStyle default interpolate linear\n' +
|
||||||
|
'e1@{curve: stepAfter}'
|
||||||
|
);
|
||||||
|
|
||||||
|
const vert = flow.parser.yy.getVertices();
|
||||||
|
const edges = flow.parser.yy.getEdges();
|
||||||
|
|
||||||
|
expect(edges[0].interpolate).toBe('stepAfter');
|
||||||
|
expect(edges.defaultInterpolate).toBe('linear');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle edge curve properties using edge ID mixed with line interpolation', function () {
|
||||||
|
const res = flow.parser.parse(
|
||||||
|
'graph TD\n' +
|
||||||
|
'A e1@-->B-->D\n' +
|
||||||
|
'A-->C e4@-->D-->E\n' +
|
||||||
|
'linkStyle default interpolate linear\n' +
|
||||||
|
'linkStyle 1 interpolate basis\n' +
|
||||||
|
'e1@{curve: monotoneX}\n' +
|
||||||
|
'e4@{curve: stepBefore}'
|
||||||
|
);
|
||||||
|
|
||||||
|
const vert = flow.parser.yy.getVertices();
|
||||||
|
const edges = flow.parser.yy.getEdges();
|
||||||
|
|
||||||
|
expect(edges[0].interpolate).toBe('monotoneX');
|
||||||
|
expect(edges[1].interpolate).toBe('basis');
|
||||||
|
expect(edges.defaultInterpolate).toBe('linear');
|
||||||
|
expect(edges[3].interpolate).toBe('stepBefore');
|
||||||
|
expect(edges.defaultInterpolate).toBe('linear');
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle line interpolation multi-numbered definitions', function () {
|
it('should handle line interpolation multi-numbered definitions', function () {
|
||||||
const res = flow.parser.parse(
|
const res = flow.parser.parse(
|
||||||
'graph TD\n' + 'A-->B\n' + 'A-->C\n' + 'linkStyle 0,1 interpolate basis'
|
'graph TD\n' + 'A-->B\n' + 'A-->C\n' + 'linkStyle 0,1 interpolate basis'
|
||||||
|
Reference in New Issue
Block a user