mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-26 01:14:09 +02:00
test: Update nodes test
This commit is contained in:
@@ -16,7 +16,7 @@ export const insertNode = async (elem, node, renderOptions) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const shapeHandler = shapes.get(node.shape);
|
const shapeHandler = shapes[node.shape];
|
||||||
|
|
||||||
if (!shapeHandler) {
|
if (!shapeHandler) {
|
||||||
throw new Error(`No such shape: ${node.shape}. Please check your syntax.`);
|
throw new Error(`No such shape: ${node.shape}. Please check your syntax.`);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import exp from 'constants';
|
import { shapes } from './shapes.js';
|
||||||
import { shapes } from './nodes.js';
|
import { describe, it, expect } from 'vitest';
|
||||||
|
|
||||||
describe('Test Alias for shapes', function () {
|
describe('Test Alias for shapes', function () {
|
||||||
// for each shape in docs/syntax/flowchart.md, along with its semantic name, short name, and alias name, add a test case
|
// for each shape in docs/syntax/flowchart.md, along with its semantic name, short name, and alias name, add a test case
|
||||||
@@ -434,33 +434,31 @@ export const shapesDefs: ShapeDefinition[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const generateShapeMap = () => {
|
const generateShapeMap = () => {
|
||||||
const shapeMap = new Map<string, ShapeHandler>(
|
// These are the shapes that didn't have documentation present.
|
||||||
// These are the shapes that didn't have documentation present.
|
const shapeMap: Record<string, ShapeHandler> = {
|
||||||
Object.entries({
|
// States
|
||||||
// States
|
state,
|
||||||
state,
|
stateStart,
|
||||||
stateStart,
|
stateEnd,
|
||||||
stateEnd,
|
forkJoin,
|
||||||
forkJoin,
|
choice,
|
||||||
choice,
|
note,
|
||||||
note,
|
|
||||||
|
|
||||||
// Rectangles
|
// Rectangles
|
||||||
rectWithTitle,
|
rectWithTitle,
|
||||||
roundedRect,
|
roundedRect,
|
||||||
squareRect,
|
squareRect,
|
||||||
labelRect,
|
labelRect,
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
iconSquare,
|
iconSquare,
|
||||||
iconCircle,
|
iconCircle,
|
||||||
icon,
|
icon,
|
||||||
iconRounded,
|
iconRounded,
|
||||||
imageSquare,
|
imageSquare,
|
||||||
|
|
||||||
anchor,
|
anchor,
|
||||||
})
|
};
|
||||||
);
|
|
||||||
|
|
||||||
for (const shape of shapesDefs) {
|
for (const shape of shapesDefs) {
|
||||||
for (const alias of [
|
for (const alias of [
|
||||||
@@ -468,7 +466,7 @@ const generateShapeMap = () => {
|
|||||||
...(shape.aliases ?? []),
|
...(shape.aliases ?? []),
|
||||||
...(shape.legacyAliases ?? []),
|
...(shape.legacyAliases ?? []),
|
||||||
]) {
|
]) {
|
||||||
shapeMap.set(alias, shape.handler);
|
shapeMap[alias] = shape.handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return shapeMap;
|
return shapeMap;
|
||||||
|
|||||||
Reference in New Issue
Block a user