/** * Tests for Element Crafting Recipes */ import { describe, it, expect } from 'vitest'; import { ELEMENTS } from '../constants'; describe('Element Crafting Recipes', () => { it('should have valid ingredient references', () => { Object.entries(ELEMENTS).forEach(([id, def]) => { if (def.recipe) { def.recipe.forEach(ingredient => { expect(ELEMENTS[ingredient]).toBeDefined(); }); } }); }); it('should not have circular recipes', () => { const visited = new Set(); const checkCircular = (id: string, path: string[]): boolean => { if (path.includes(id)) return true; const def = ELEMENTS[id]; if (!def.recipe) return false; return def.recipe.some(ing => checkCircular(ing, [...path, id])); }; Object.keys(ELEMENTS).forEach(id => { expect(checkCircular(id, [])).toBe(false); }); }); });