Error Message Changed

This commit is contained in:
RounakJoshi09 2023-10-11 20:40:14 +05:30
parent ce3d9fcdde
commit 995449cbf6
2 changed files with 15 additions and 14 deletions

View File

@ -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;

View File

@ -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 () {