test: set up Vitest with 61 frontend tests
Add Vitest + testing-library/react + jsdom for frontend testing. Tests cover: cn() utility (6), usePermissions hook (27), useTreeValidation hook (22), and userPreferencesStore (6). CI updated to run frontend tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
28
frontend/src/lib/utils.test.ts
Normal file
28
frontend/src/lib/utils.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { cn } from './utils'
|
||||
|
||||
describe('cn', () => {
|
||||
it('merges class names', () => {
|
||||
expect(cn('foo', 'bar')).toBe('foo bar')
|
||||
})
|
||||
|
||||
it('handles conditional classes', () => {
|
||||
expect(cn('base', false && 'hidden', 'visible')).toBe('base visible')
|
||||
})
|
||||
|
||||
it('deduplicates tailwind classes', () => {
|
||||
expect(cn('p-4', 'p-2')).toBe('p-2')
|
||||
})
|
||||
|
||||
it('handles undefined and null', () => {
|
||||
expect(cn('foo', undefined, null, 'bar')).toBe('foo bar')
|
||||
})
|
||||
|
||||
it('handles empty inputs', () => {
|
||||
expect(cn()).toBe('')
|
||||
})
|
||||
|
||||
it('merges conflicting tailwind utilities', () => {
|
||||
expect(cn('text-red-500', 'text-blue-500')).toBe('text-blue-500')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user