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

View File

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

View File

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