Files
goodgo-platform/apps/web/lib/__tests__/utils.spec.ts
Ho Ngoc Hai cd2abdba7b 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>
2026-04-08 14:59:00 +07:00

27 lines
710 B
TypeScript

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