mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-26 10:49:38 +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) {
|
||||
throw new Error(`No such shape: ${node.shape}. Please check your syntax.`);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import exp from 'constants';
|
||||
import { shapes } from './nodes.js';
|
||||
import { shapes } from './shapes.js';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
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
|
@@ -434,33 +434,31 @@ export const shapesDefs: ShapeDefinition[] = [
|
||||
];
|
||||
|
||||
const generateShapeMap = () => {
|
||||
const shapeMap = new Map<string, ShapeHandler>(
|
||||
// These are the shapes that didn't have documentation present.
|
||||
Object.entries({
|
||||
// States
|
||||
state,
|
||||
stateStart,
|
||||
stateEnd,
|
||||
forkJoin,
|
||||
choice,
|
||||
note,
|
||||
// These are the shapes that didn't have documentation present.
|
||||
const shapeMap: Record<string, ShapeHandler> = {
|
||||
// States
|
||||
state,
|
||||
stateStart,
|
||||
stateEnd,
|
||||
forkJoin,
|
||||
choice,
|
||||
note,
|
||||
|
||||
// Rectangles
|
||||
rectWithTitle,
|
||||
roundedRect,
|
||||
squareRect,
|
||||
labelRect,
|
||||
// Rectangles
|
||||
rectWithTitle,
|
||||
roundedRect,
|
||||
squareRect,
|
||||
labelRect,
|
||||
|
||||
// Icons
|
||||
iconSquare,
|
||||
iconCircle,
|
||||
icon,
|
||||
iconRounded,
|
||||
imageSquare,
|
||||
// Icons
|
||||
iconSquare,
|
||||
iconCircle,
|
||||
icon,
|
||||
iconRounded,
|
||||
imageSquare,
|
||||
|
||||
anchor,
|
||||
})
|
||||
);
|
||||
anchor,
|
||||
};
|
||||
|
||||
for (const shape of shapesDefs) {
|
||||
for (const alias of [
|
||||
@@ -468,7 +466,7 @@ const generateShapeMap = () => {
|
||||
...(shape.aliases ?? []),
|
||||
...(shape.legacyAliases ?? []),
|
||||
]) {
|
||||
shapeMap.set(alias, shape.handler);
|
||||
shapeMap[alias] = shape.handler;
|
||||
}
|
||||
}
|
||||
return shapeMap;
|
||||
|
Reference in New Issue
Block a user