/**
 * Tests for src/lib/utils.ts utility functions
 */

import { describe, it, expect } from 'vitest';
import { cn } from '@/lib/utils';

describe('cn utility function', () => {
  it('should handle empty input', () => {
    expect(cn()).toBe('');
  });

  it('should handle single class string', () => {
    expect(cn('px-4')).toBe('px-4');
  });

  it('should handle multiple class strings', () => {
    expect(cn('px-4', 'py-2', 'bg-blue-500')).toBe('px-4 py-2 bg-blue-500');
  });

  it('should merge conflicting Tailwind classes (last one wins)', () => {
    expect(cn('px-4', 'px-2')).toBe('px-2');
    expect(cn('bg-red-500', 'bg-blue-500')).toBe('bg-blue-500');
  });

  it('should handle conditional classes with null/undefined', () => {
    expect(cn('px-4', null, 'py-2', undefined)).toBe('px-4 py-2');
  });

  it('should handle arrays of classes', () => {
    expect(cn(['px-4', 'py-2'])).toBe('px-4 py-2');
  });

  it('should handle objects with boolean values', () => {
    expect(cn({ 'px-4': true, 'py-2': false, 'bg-blue-500': true })).toBe('px-4 bg-blue-500');
  });

  it('should handle complex mixed inputs', () => {
    expect(
      cn('base-class', ['array-class'], { 'conditional-class': true, 'removed-class': false }, null)
    ).toBe('base-class array-class conditional-class');
  });

  it('should handle empty arrays and objects', () => {
    expect(cn([])).toBe('');
    expect(cn({})).toBe('');
  });

  it('should handle conflicting classes in complex scenarios', () => {
    expect(cn('text-sm', ['text-lg'], { 'text-xl': false })).toBe('text-lg');
  });
});
