|
| 1 | +// lib/svg/generator.themeLookup.test.ts |
| 2 | + |
| 3 | +import { describe, it, expect, vi } from 'vitest'; |
| 4 | +import { resolveFont } from './generator'; |
| 5 | + |
| 6 | +describe('themeLookup / font resolving behavior', () => { |
| 7 | + it('should return null if no font parameter is provided', () => { |
| 8 | + expect(resolveFont()).toBeNull(); |
| 9 | + expect(resolveFont(null)).toBeNull(); |
| 10 | + expect(resolveFont('')).toBeNull(); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should resolve bundled fonts standard parameters correctly', () => { |
| 14 | + expect(resolveFont('jetbrains')).toBe('"JetBrains Mono", monospace'); |
| 15 | + expect(resolveFont('fira')).toBe('"Fira Code", monospace'); |
| 16 | + expect(resolveFont('roboto')).toBe('"Roboto", sans-serif'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('should resolve previously missing bundled fonts without dynamic dynamic google font trigger', () => { |
| 20 | + expect(resolveFont('syncopate')).toBe('"Syncopate", sans-serif'); |
| 21 | + expect(resolveFont('spacegrotesk')).toBe('"Space Grotesk", sans-serif'); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should remain robust and case-insensitive under out-of-bounds or spaced inputs', () => { |
| 25 | + expect(resolveFont('JETBRAINS')).toBe('"JetBrains Mono", monospace'); |
| 26 | + expect(resolveFont('space grotesk')).toBe('"Space Grotesk", sans-serif'); |
| 27 | + expect(resolveFont('JetBrains Mono')).toBe('"JetBrains Mono", monospace'); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should fall back gracefully to a standard sans-serif font stack for unrecognized dynamic fonts', () => { |
| 31 | + expect(resolveFont('Comic Sans')).toBe('"Comic Sans", sans-serif'); |
| 32 | + expect(resolveFont('custom-font')).toBe('"custom-font", sans-serif'); |
| 33 | + }); |
| 34 | +}); |
0 commit comments