import { describe, it, expect } from 'vitest'; import { domainColor, domainIcon, domainLabel, DOMAIN_VIEWER_PALETTE } from './domain-palette'; describe('DOMAIN_VIEWER_PALETTE', () => { it('has exactly the v1 palette entries (musehub#117 DOM_09)', () => { expect(Object.keys(DOMAIN_VIEWER_PALETTE).sort()).toEqual( ['generic', 'piano_roll', 'symbol_graph'].sort() ); }); }); describe('domainColor', () => { it('returns the symbol_graph color', () => { expect(domainColor('symbol_graph')).toBe('#58a6ff'); }); it('returns the piano_roll color', () => { expect(domainColor('piano_roll')).toBe('#bc8cff'); }); it('falls back to generic color for unknown viewer types', () => { expect(domainColor('totally_unknown')).toBe(DOMAIN_VIEWER_PALETTE.generic.color); }); }); describe('domainIcon', () => { it('returns distinct icons per known viewer type', () => { expect(domainIcon('symbol_graph')).toBe('⬡'); expect(domainIcon('piano_roll')).toBe('♪'); }); it('falls back to generic icon for unknown viewer types', () => { expect(domainIcon('nonsense')).toBe(DOMAIN_VIEWER_PALETTE.generic.icon); }); }); describe('domainLabel', () => { it('prefers a real domain name over the palette label', () => { expect(domainLabel('symbol_graph', 'My Domain')).toBe('My Domain'); }); it('falls back to the palette label when name is missing', () => { expect(domainLabel('piano_roll')).toBe('MIDI'); }); it('falls back to the palette label when name is "Unknown"', () => { expect(domainLabel('symbol_graph', 'Unknown')).toBe('Code'); }); it('falls back to generic label for unknown viewer types with no name', () => { expect(domainLabel('mystery')).toBe('Generic'); }); });