mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-12-03 02:54:06 +01:00
Error Message Changed
This commit is contained in:
@@ -193,10 +193,11 @@ export const updateLinkInterpolate = function (positions, interp) {
|
|||||||
export const updateLink = function (positions, style) {
|
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(
|
throw new Error(
|
||||||
`The index for linkStyle is out of bounds. (Help: Ensure that the index is within the range of existing edges.)`
|
`The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${
|
||||||
|
edges.length - 1
|
||||||
|
}. (Help: Ensure that the index is within the range of existing edges.)`
|
||||||
);
|
);
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
if (pos === 'default') {
|
if (pos === 'default') {
|
||||||
edges.defaultStyle = style;
|
edges.defaultStyle = style;
|
||||||
|
|||||||
@@ -287,17 +287,17 @@ describe('[Style] when parsing', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle style definitions within number of edges', function () {
|
it('should handle style definitions within number of edges', function () {
|
||||||
try {
|
expect(() =>
|
||||||
flow.parser.parse(`graph TD
|
flow.parser
|
||||||
A-->B
|
.parse(
|
||||||
linkStyle 1 stroke-width:1px;`);
|
`graph TD
|
||||||
// Fail test if above expression doesn't throw anything.
|
A-->B
|
||||||
expect(true).toBe(false);
|
linkStyle 1 stroke-width:1px;`
|
||||||
} catch (e) {
|
)
|
||||||
expect(e.message).toBe(
|
.toThrow(
|
||||||
`The index for linkStyle is out of bounds. (Help: Ensure that the index is within the range of existing edges.)`
|
'The index 1 for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and 0. (Help: Ensure that the index is within the range of existing edges.)'
|
||||||
);
|
)
|
||||||
}
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle style definitions within number of edges', function () {
|
it('should handle style definitions within number of edges', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user