import { render } from '@testing-library/react' import { describe, expect, it } from 'vitest' import { Icon, type IconName } from '../src/components/Icon' import { iconMap, iconRegistry } from '../src/components/icon-registry' describe('icon registry (single source of truth)', () => { it('has unique names', () => { const names = iconRegistry.map(entry => entry.name) expect(new Set(names).size).toBe(names.length) }) it('maps every name (including aliases) to a real registry component', () => { const components = new Set(iconRegistry.map(entry => entry.component)) for (const [name, component] of Object.entries(iconMap)) { expect(components.has(component), `icon "${name}" has no canonical twin in the registry`).toBe(true) } }) it('resolves every registry entry through iconMap', () => { for (const entry of iconRegistry) { expect(iconMap[entry.name]).toBe(entry.component) } }) it('renders a registry icon by name', () => { const { container } = render() expect(container.querySelector('svg')).toBeInTheDocument() }) it('throws on unknown names in dev instead of silently rendering a wrong glyph', () => { expect(() => render()).toThrow(/Unknown icon name/) }) })