import { describe, expect, it } from 'vitest'; import { NODE_CATEGORIES, NODE_META, groupNodeTypesByCategory, type NodeType, } from './shared'; const ALL_TYPES = Object.keys(NODE_META) as NodeType[]; describe('node categories', () => { it('assigns every node type to a known category', () => { const known = new Set(NODE_CATEGORIES.map((c) => c.id)); for (const type of ALL_TYPES) { expect(known.has(NODE_META[type].category)).toBe(true); } }); }); describe('groupNodeTypesByCategory', () => { it('keeps the categories in NODE_CATEGORIES order and drops empty ones', () => { // Only messaging + flow types — the logic group must not appear. const groups = groupNodeTypesByCategory(['send_message', 'start', 'end']); expect(groups.map((g) => g.id)).toEqual(['messaging', 'flow']); }); it('preserves the input order within a category', () => { const groups = groupNodeTypesByCategory([ 'send_media', 'send_message', 'send_buttons', ]); expect(groups).toHaveLength(1); expect(groups[0].types).toEqual([ 'send_media', 'send_message', 'send_buttons', ]); }); it('partitions the full type list without losing or duplicating a type', () => { const grouped = groupNodeTypesByCategory(ALL_TYPES).flatMap((g) => g.types); expect([...grouped].sort()).toEqual([...ALL_TYPES].sort()); }); });