domain-palette.test.ts
typescript
sha256:0521dce9aca20da6ab4d9ebee6de75ab876bd82cddbc6bd4897d1ac6ecd11d3d
docs(musehub#129): freeze Phase 1 OG repo card design
Human
14 days ago
| 1 | import { describe, it, expect } from 'vitest'; |
| 2 | import { domainColor, domainIcon, domainLabel, DOMAIN_VIEWER_PALETTE } from './domain-palette'; |
| 3 | |
| 4 | describe('DOMAIN_VIEWER_PALETTE', () => { |
| 5 | it('has exactly the v1 palette entries (musehub#117 DOM_09)', () => { |
| 6 | expect(Object.keys(DOMAIN_VIEWER_PALETTE).sort()).toEqual( |
| 7 | ['generic', 'piano_roll', 'symbol_graph'].sort() |
| 8 | ); |
| 9 | }); |
| 10 | }); |
| 11 | |
| 12 | describe('domainColor', () => { |
| 13 | it('returns the symbol_graph color', () => { |
| 14 | expect(domainColor('symbol_graph')).toBe('#58a6ff'); |
| 15 | }); |
| 16 | |
| 17 | it('returns the piano_roll color', () => { |
| 18 | expect(domainColor('piano_roll')).toBe('#bc8cff'); |
| 19 | }); |
| 20 | |
| 21 | it('falls back to generic color for unknown viewer types', () => { |
| 22 | expect(domainColor('totally_unknown')).toBe(DOMAIN_VIEWER_PALETTE.generic.color); |
| 23 | }); |
| 24 | }); |
| 25 | |
| 26 | describe('domainIcon', () => { |
| 27 | it('returns distinct icons per known viewer type', () => { |
| 28 | expect(domainIcon('symbol_graph')).toBe('⬡'); |
| 29 | expect(domainIcon('piano_roll')).toBe('♪'); |
| 30 | }); |
| 31 | |
| 32 | it('falls back to generic icon for unknown viewer types', () => { |
| 33 | expect(domainIcon('nonsense')).toBe(DOMAIN_VIEWER_PALETTE.generic.icon); |
| 34 | }); |
| 35 | }); |
| 36 | |
| 37 | describe('domainLabel', () => { |
| 38 | it('prefers a real domain name over the palette label', () => { |
| 39 | expect(domainLabel('symbol_graph', 'My Domain')).toBe('My Domain'); |
| 40 | }); |
| 41 | |
| 42 | it('falls back to the palette label when name is missing', () => { |
| 43 | expect(domainLabel('piano_roll')).toBe('MIDI'); |
| 44 | }); |
| 45 | |
| 46 | it('falls back to the palette label when name is "Unknown"', () => { |
| 47 | expect(domainLabel('symbol_graph', 'Unknown')).toBe('Code'); |
| 48 | }); |
| 49 | |
| 50 | it('falls back to generic label for unknown viewer types with no name', () => { |
| 51 | expect(domainLabel('mystery')).toBe('Generic'); |
| 52 | }); |
| 53 | }); |
File History
1 commit
sha256:6ad6d62107bbd6940c52d63327966b8a65c6391f4a3da6cd9e7548ba4b38bc48
feat(musehub#129): OG repo preview cards — endpoint, cache,…
Human
minor
⚠
14 days ago