import { describe, expect, it } from 'vitest'; import { DEFAULT_FONTS, FONT_CATALOG, fontEntry, fontSlug, fontStack } from './fonts'; describe('font catalog (issue #66, ADR 0016)', () => { it('is non-trivial and has unique families', () => { expect(FONT_CATALOG.length).toBeGreaterThanOrEqual(15); const families = FONT_CATALOG.map((f) => f.family); expect(new Set(families).size).toBe(families.length); }); it('every entry carries license info and weights (what the build step enforces)', () => { for (const entry of FONT_CATALOG) { expect(entry.family, entry.id).toBeTruthy(); expect(entry.license, entry.family).toMatch(/OFL-1\.1|Apache-2\.0/); expect(entry.licenseUrl, entry.family).toMatch(/^https:\/\//); expect(entry.weights.length, entry.family).toBeGreaterThan(0); expect(entry.id, entry.family).toMatch(/^[a-z0-9-]+$/); } }); it('the vision defaults exist in the catalog at their weights', () => { for (const slot of ['heading', 'body', 'mono'] as const) { const { family, weight } = DEFAULT_FONTS[slot]; const entry = fontEntry(family); expect(entry, `${slot} default family`).toBeDefined(); expect(entry!.weights, `${family} @ ${weight}`).toContain(weight); } }); it('builds a stack with the family ahead of a category fallback', () => { expect(fontStack('Roboto')).toBe("'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif"); expect(fontStack('Merriweather')).toContain("'Merriweather'"); expect(fontStack('Fira Code')).toContain('monospace'); // An unknown family falls back to the sans system stack, no bogus family. expect(fontStack('Nonexistent Font')).not.toContain('Nonexistent'); }); it('slugs families to the on-disk /fonts layout', () => { expect(fontSlug('Source Serif 4')).toBe('source-serif-4'); expect(fontSlug('IBM Plex Mono')).toBe('ibm-plex-mono'); }); });