import { describe, expect, it } from 'vitest' import { avatarColors, avatarHue, initials } from '../src/avatar' describe('initials', () => { it('takes the first letter of the first two words', () => { expect(initials('Acme UK Compliance Group')).toBe('AU') expect(initials('hamiltel')).toBe('H') }) it('falls back to ? for empty input', () => { expect(initials('')).toBe('?') expect(initials(' ')).toBe('?') }) }) describe('avatarHue', () => { it('is deterministic', () => { expect(avatarHue('Hamiltel')).toBe(avatarHue('Hamiltel')) }) it('stays in [0, 360)', () => { for (const n of ['a', 'Acme', 'Zed Systems', '৪২']) { const h = avatarHue(n) expect(h).toBeGreaterThanOrEqual(0) expect(h).toBeLessThan(360) } }) }) describe('avatarColors', () => { it('returns hsl strings derived from the hue', () => { const { bg, fg } = avatarColors('Hamiltel') const h = avatarHue('Hamiltel') expect(bg).toContain(`hsl(${h}`) expect(fg).toContain(`hsl(${h}`) }) })