Team Ai
Apppublic

Underground-Digital/Workflow-Engine

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
classnames.spec.ts56 linesDownload Raw Back to utils
1import cn from './classnames'2 3describe('classnames', () => {4  test('classnames libs feature', () => {5    expect(cn('foo')).toBe('foo')6    expect(cn('foo', 'bar')).toBe('foo bar')7    expect(cn(['foo', 'bar'])).toBe('foo bar')8 9    expect(cn(undefined)).toBe('')10    expect(cn(null)).toBe('')11    expect(cn(false)).toBe('')12 13    expect(cn({14      foo: true,15      bar: false,16      baz: true,17    })).toBe('foo baz')18  })19 20  test('tailwind-merge', () => {21    expect(cn('p-0')).toBe('p-0')22    expect(cn('text-right text-center text-left')).toBe('text-left')23    expect(cn('pl-4 p-8')).toBe('p-8')24    expect(cn('m-[2px] m-[4px]')).toBe('m-[4px]')25    expect(cn('m-1 m-[4px]')).toBe('m-[4px]')26    expect(cn('overflow-x-auto hover:overflow-x-hidden overflow-x-scroll')).toBe(27      'hover:overflow-x-hidden overflow-x-scroll',28    )29    expect(cn('h-10 h-min')).toBe('h-min')30    expect(cn('bg-grey-5 bg-hotpink')).toBe('bg-hotpink')31 32    expect(cn('hover:block hover:inline')).toBe('hover:inline')33 34    expect(cn('font-medium !font-bold')).toBe('font-medium !font-bold')35    expect(cn('!font-medium !font-bold')).toBe('!font-bold')36 37    expect(cn('text-gray-100 text-primary-200')).toBe('text-primary-200')38    expect(cn('text-some-unknown-color text-components-input-bg-disabled text-primary-200')).toBe('text-primary-200')39    expect(cn('bg-some-unknown-color bg-components-input-bg-disabled bg-primary-200')).toBe('bg-primary-200')40 41    expect(cn('border-t border-white/10')).toBe('border-t border-white/10')42    expect(cn('border-t border-white')).toBe('border-t border-white')43    expect(cn('text-3.5xl text-black')).toBe('text-3.5xl text-black')44  })45 46  test('classnames combined with tailwind-merge', () => {47    expect(cn('text-right', {48      'text-center': true,49    })).toBe('text-center')50 51    expect(cn('text-right', {52      'text-center': false,53    })).toBe('text-right')54  })55})56