next.js/packages/next/src/next-devtools/dev-overlay/utils/cx.test.ts
cx.test.ts28 lines741 B
import { cx } from './cx'

describe('cx', () => {
  it('should return an empty string for no arguments', () => {
    expect(cx()).toBe('')
  })

  it('should join multiple string arguments with spaces', () => {
    expect(cx('foo', 'bar', 'baz')).toBe('foo bar baz')
  })

  it('should filter out falsy values', () => {
    expect(cx('foo', null, 'bar', undefined, 'baz', false)).toBe('foo bar baz')
  })

  it('should handle single string argument', () => {
    expect(cx('foo')).toBe('foo')
  })

  it('should not add extra spaces when falsy values are between strings', () => {
    expect(cx('foo', null, 'bar')).toBe('foo bar')
  })

  it('should handle all falsy values', () => {
    expect(cx(null, undefined, false)).toBe('')
  })
})
Quest for Codev2.0.0
/
SIGN IN