import tokens from '../../design-tokens.json'; import { Colors, getThemeColors } from '@/constants/theme-bridge'; function toExpectedThemeColors( palette: (typeof tokens.colors.default)['light'], ) { const colorToHsl = (v: string) => `hsl(${v.replace(/\s+/g, ', ')})`; return { text: colorToHsl(palette.foreground), background: colorToHsl(palette.background), backgroundElement: colorToHsl(palette.card), backgroundSelected: colorToHsl(palette.accent), textSecondary: colorToHsl(palette.mutedForeground), border: colorToHsl(palette.border), input: colorToHsl(palette.input), ring: colorToHsl(palette.ring), primary: colorToHsl(palette.primary), primaryForeground: colorToHsl(palette.primaryForeground), secondary: colorToHsl(palette.secondary), secondaryForeground: colorToHsl(palette.secondaryForeground), muted: colorToHsl(palette.muted), mutedForeground: colorToHsl(palette.mutedForeground), accent: colorToHsl(palette.accent), accentForeground: colorToHsl(palette.accentForeground), card: colorToHsl(palette.card), cardForeground: colorToHsl(palette.cardForeground), popover: colorToHsl(palette.popover), popoverForeground: colorToHsl(palette.popoverForeground), destructive: colorToHsl(palette.destructive), destructiveForeground: colorToHsl(palette.destructiveForeground), success: colorToHsl(palette.success), successForeground: colorToHsl(palette.successForeground), warning: colorToHsl(palette.warning), warningForeground: colorToHsl(palette.warningForeground), info: colorToHsl(palette.info), infoForeground: colorToHsl(palette.infoForeground), }; } describe('theme bridge', () => { test('getThemeColors returns correct colors for light and dark', () => { expect(getThemeColors('light')).toEqual( toExpectedThemeColors(tokens.colors.default.light), ); expect(getThemeColors('dark')).toEqual( toExpectedThemeColors(tokens.colors.default.dark), ); }); test('Colors precomputed matches getThemeColors', () => { expect(Colors.light).toEqual(getThemeColors('light')); expect(Colors.dark).toEqual(getThemeColors('dark')); }); });