test: Update nodes test

This commit is contained in:
Sidharth Vinod
2024-10-04 00:05:38 +05:30
parent 218bfe1603
commit 0ae4f97036
3 changed files with 26 additions and 28 deletions

View File

@@ -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.`);

View File

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

View File

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