mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Error Message Changed
This commit is contained in:
parent
ce3d9fcdde
commit
995449cbf6
@ -193,10 +193,11 @@ export const updateLinkInterpolate = function (positions, interp) {
|
||||
export const updateLink = function (positions, style) {
|
||||
positions.forEach(function (pos) {
|
||||
if (pos >= edges.length) {
|
||||
let error = new Error(
|
||||
`The index for linkStyle is out of bounds. (Help: Ensure that the index is within the range of existing edges.)`
|
||||
throw new Error(
|
||||
`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') {
|
||||
edges.defaultStyle = style;
|
||||
|
@ -287,17 +287,17 @@ describe('[Style] when parsing', () => {
|
||||
});
|
||||
|
||||
it('should handle style definitions within number of edges', function () {
|
||||
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.)`
|
||||
);
|
||||
}
|
||||
expect(() =>
|
||||
flow.parser
|
||||
.parse(
|
||||
`graph TD
|
||||
A-->B
|
||||
linkStyle 1 stroke-width:1px;`
|
||||
)
|
||||
.toThrow(
|
||||
'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 () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user