import { describe, expect, it } from 'vitest'; import { cleanupClassNameTemplateWhitespace } from './class-name-whitespace-cleanup'; describe('cleanupClassNameTemplateWhitespace', () => { it('should normalize whitespace for clsx template arguments', () => { const sourceCode = ` const value = clsx(\` univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-justify-self-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700 \`, { active: true, }); `; expect(cleanupClassNameTemplateWhitespace(sourceCode, '/tmp/example.tsx')).toContain( 'clsx("univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-justify-self-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700", {' ); }); it('should normalize whitespace for conditional clsx template arguments', () => { const sourceCode = ` const value = clsx( "univer-relative univer-transition-all univer-duration-150", isDraggingItem && "univer-opacity-0", dragOverId === itemId && !isDraggingItem && \` univer-bg-primary-50/60 dark:!univer-bg-primary-900/20 univer-rounded univer-border univer-border-primary-200 dark:!univer-border-primary-700 \` ); `; expect(cleanupClassNameTemplateWhitespace(sourceCode, '/tmp/example.tsx')).toContain( 'dragOverId === itemId && !isDraggingItem && "univer-bg-primary-50/60 dark:!univer-bg-primary-900/20 univer-rounded univer-border univer-border-primary-200 dark:!univer-border-primary-700"' ); }); it('should normalize whitespace for className template literals', () => { const sourceCode = ` const value = (
); `; expect(cleanupClassNameTemplateWhitespace(sourceCode, '/tmp/example.tsx')).toContain( 'className={"univer-box-border univer-grid univer-grid-cols-5 univer-gap-2 univer-text-gray-600 dark:!univer-text-gray-200"}' ); }); it('should normalize whitespace for className string literals', () => { const sourceCode = ` const value = (