import type { Config, TransformedToken } from 'style-dictionary/types' import { describe, expect, it } from 'vitest' import { filter, transform } from './tailwind-animation-token.js' const createMockToken = ( path: string[], type: string, value: unknown, usesDtcg = true, ): TransformedToken => ({ name: path.join('-'), value, type, path, original: {}, filePath: '', isSource: false, ...(usesDtcg ? { $type: type, $value: value } : {}), }) as TransformedToken const createMockConfig = (): Config => ({ platforms: {}, source: [], include: [], }) describe('tailwind/v4/animation', () => { describe('filter', () => { it('should return true for tokens with $type animation', () => { const token = createMockToken( ['animate', 'fade', 'in'], 'animation', 'fade-in', ) const config = createMockConfig() expect(filter(token, config)).toBeTruthy() }) it('should return false for tokens without $type animation', () => { const token = createMockToken( ['color', 'primary', 'default'], 'color', '#f00', ) const config = createMockConfig() expect(filter(token, config)).toBeFalsy() }) it('should handle non-DTCG tokens', () => { const token = createMockToken( ['animate', 'fade', 'in'], 'animation', 'fade-in', false, ) const config = createMockConfig() expect(filter(token, { ...config, usesDtcg: false })).toBeTruthy() }) }) describe('transform', () => { it('should process animation tokens correctly', () => { const token = createMockToken(['animate', 'fade', 'in'], 'animation', { name: 'spin', duration: '2s', timingFunction: 'linear', }) const config = createMockConfig() const output = transform(token, config, {}) expect(output).toEqual('2s linear spin') }) }) it('should handle optional delay', () => { const token = createMockToken(['animate', 'fade', 'in'], 'animation', { name: 'spin', duration: '2s', timingFunction: 'linear', delay: '3s', }) const config = createMockConfig() const output = transform(token, config, {}) expect(output).toEqual('2s linear 3s spin') }) it('should handle optional iterationCount', () => { const token = createMockToken(['animate', 'fade', 'in'], 'animation', { name: 'spin', duration: '2s', timingFunction: 'linear', iterationCount: 'infinite', }) const config = createMockConfig() const output = transform(token, config, {}) expect(output).toEqual('2s linear infinite spin') }) })