test(web): add Vitest setup and unit tests for validations and utils
- Add vitest config and test script to web app - Auth validation tests: phone format, password rules, registration flow - Listing validation tests: all schema steps, constants, merged schema - Utils tests: cn() class merging with Tailwind conflict resolution - 36 tests across 3 test files Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
26
apps/web/lib/__tests__/utils.spec.ts
Normal file
26
apps/web/lib/__tests__/utils.spec.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { cn } from '../utils';
|
||||
|
||||
describe('cn', () => {
|
||||
it('should merge class names', () => {
|
||||
expect(cn('foo', 'bar')).toBe('foo bar');
|
||||
});
|
||||
|
||||
it('should handle conditional classes', () => {
|
||||
expect(cn('base', false && 'hidden', 'visible')).toBe('base visible');
|
||||
});
|
||||
|
||||
it('should merge conflicting Tailwind classes', () => {
|
||||
expect(cn('px-4', 'px-6')).toBe('px-6');
|
||||
expect(cn('text-red-500', 'text-blue-500')).toBe('text-blue-500');
|
||||
});
|
||||
|
||||
it('should handle empty inputs', () => {
|
||||
expect(cn()).toBe('');
|
||||
expect(cn('')).toBe('');
|
||||
});
|
||||
|
||||
it('should handle arrays', () => {
|
||||
expect(cn(['foo', 'bar'])).toBe('foo bar');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user