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:
Ho Ngoc Hai
2026-04-08 14:59:00 +07:00
parent 6baa4707de
commit cd2abdba7b
6 changed files with 349 additions and 2 deletions

View 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');
});
});