import { describe, expect, it } from 'vitest'; import { cx } from './cx'; describe('cx', () => { it('joins strings with a single space', () => { expect(cx('px-2', 'py-1')).toBe('px-2 py-1'); }); it('drops every falsy value', () => { expect(cx('a', false, null, undefined, '', 0, 'b')).toBe('a b'); }); it('keeps truthy numbers, since a class can legitimately be numeric', () => { expect(cx(1, 'a')).toBe('1 a'); }); it('flattens arrays, including nested ones', () => { expect(cx(['a', ['b', ['c']]], 'd')).toBe('a b c d'); }); it('takes object keys whose value is truthy', () => { expect(cx({ a: true, b: false, c: 1, d: 0, e: 'yes' })).toBe('a c e'); }); it('supports the conditional idiom components rely on', () => { const disabled = false; const active = true; expect(cx('base', active && 'is-active', disabled && 'is-disabled')).toBe('base is-active'); }); it('mixes every input form in one call', () => { expect(cx('a', ['b', { c: true, d: false }], undefined, { e: 1 })).toBe('a b c e'); }); it('returns an empty string when nothing survives', () => { expect(cx(null, undefined, false, {}, [])).toBe(''); }); });