import { describe, expect, it } from 'vitest' import { generateThemeVariables } from '../utils/convertSemanticsToken' import { createFlattenTheme } from '@/designTokens/utils' describe('design token utils', () => { it('flattens nested theme objects without non-null assertions', () => { expect(createFlattenTheme({ primary: { base: '#0c419a', }, spacing: { md: 16, }, })).toEqual({ 'primary-base': '#0c419a', 'spacing-md': 16, }) }) it('throws when a flattened theme value is undefined', () => { expect(() => createFlattenTheme({ primary: { base: undefined, }, } as unknown as Parameters[0])).toThrowError('Missing theme value for key "primary-base"') }) it('generates semantic theme variables from token categories', () => { expect(generateThemeVariables({ colors: { background: { main: '#ffffff', }, text: { base: '#222324', }, }, })).toEqual({ onBackgroundMain: '#ffffff', onTextBase: '#222324', }) }) it('throws when a semantic token value is undefined', () => { expect(() => generateThemeVariables({ colors: { background: { main: undefined, }, }, } as unknown as Parameters[0])).toThrowError('Missing semantic token "main" in category "background"') }) })