mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Added test suggested on PR
This commit is contained in:
parent
cdb4639aa4
commit
ce3d9fcdde
@ -194,7 +194,7 @@ export const updateLink = function (positions, style) {
|
||||
positions.forEach(function (pos) {
|
||||
if (pos >= edges.length) {
|
||||
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;
|
||||
}
|
||||
|
@ -287,7 +287,23 @@ describe('[Style] when parsing', () => {
|
||||
});
|
||||
|
||||
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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user