summaryrefslogtreecommitdiff
path: root/src/lib/utils.test.ts
blob: 9a61d418791284ad71b6ea9bb149aa1418c69155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { describe, expect, test } from 'vitest';
import { cn } from './utils';

describe('cn', () => {
  test('merges class names and resolves tailwind conflicts', () => {
    expect(cn('px-2', 'px-4')).toBe('px-4');
  });

  test('handles conditional and falsy inputs', () => {
    expect(cn('text-sm', false && 'hidden', undefined, 'font-medium')).toBe(
      'text-sm font-medium',
    );
  });

  test('supports object and array style class inputs', () => {
    expect(
      cn(['inline-flex', ['items-center']], { 'cursor-pointer': true }),
    ).toBe('inline-flex items-center cursor-pointer');
  });
});