mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-16 13:59:54 +02:00
Added test suggested on PR
This commit is contained in:
@@ -194,7 +194,7 @@ export const updateLink = function (positions, style) {
|
|||||||
positions.forEach(function (pos) {
|
positions.forEach(function (pos) {
|
||||||
if (pos >= edges.length) {
|
if (pos >= edges.length) {
|
||||||
let error = new Error(
|
let error = new Error(
|
||||||
`Incorrect index ${pos} of linkStyle. (Help: Index must be from 0 to ${edges.length - 1})`
|
`The index for linkStyle is out of bounds. (Help: Ensure that the index is within the range of existing edges.)`
|
||||||
);
|
);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
@@ -287,7 +287,23 @@ describe('[Style] when parsing', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle style definitions within number of edges', function () {
|
it('should handle style definitions within number of edges', function () {
|
||||||
const res = flow.parser.parse('graph TD\n' + 'A-->B\n' + 'linkStyle 0 stroke-width:1px;');
|
try {
|
||||||
|
flow.parser.parse(`graph TD
|
||||||
|
A-->B
|
||||||
|
linkStyle 1 stroke-width:1px;`);
|
||||||
|
// Fail test if above expression doesn't throw anything.
|
||||||
|
expect(true).toBe(false);
|
||||||
|
} catch (e) {
|
||||||
|
expect(e.message).toBe(
|
||||||
|
`The index for linkStyle is out of bounds. (Help: Ensure that the index is within the range of existing edges.)`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle style definitions within number of edges', function () {
|
||||||
|
const res = flow.parser.parse(`graph TD
|
||||||
|
A-->B
|
||||||
|
linkStyle 0 stroke-width:1px;`);
|
||||||
|
|
||||||
const edges = flow.parser.yy.getEdges();
|
const edges = flow.parser.yy.getEdges();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user