mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-31 00:52:16 +00:00
feat: Add Jest testing infrastructure with comprehensive mocks and test scripts
- Add jest.config.js with Next.js integration, jsdom environment, module path mapping, and coverage collection for src/**/*.{js,jsx,ts,tsx}
- Add jest.setup.js with @testing-library/jest-dom, Next.js router/navigation mocks, IntersectionObserver/ResizeObserver/WebSocket/fetch mocks, localStorage/sessionStorage mocks
- Add package.json test scripts: test, test:watch, test:coverage
- Add testing dependencies: @testing-library/jest
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { cn } from '../utils'
|
||||
|
||||
describe('cn utility', () => {
|
||||
it('merges simple class names', () => {
|
||||
expect(cn('a', 'b')).toBe('a b')
|
||||
})
|
||||
|
||||
it('filters out falsy values', () => {
|
||||
expect(cn('a', false, null, undefined, 'b')).toBe('a b')
|
||||
})
|
||||
|
||||
it('deduplicates conflicting tailwind classes (twMerge)', () => {
|
||||
// tailwind-merge should keep the latter of conflicting utilities
|
||||
expect(cn('px-2', 'px-4')).toBe('px-4')
|
||||
})
|
||||
|
||||
it('handles conditional classnames via objects', () => {
|
||||
expect(cn('base', { active: true, disabled: false })).toContain('base')
|
||||
expect(cn('base', { active: true, disabled: false })).toContain('active')
|
||||
expect(cn('base', { active: true, disabled: false })).not.toContain('disabled')
|
||||
})
|
||||
|
||||
it('handles arrays of classnames', () => {
|
||||
expect(cn(['a', 'b'], 'c')).toBe('a b c')
|
||||
})
|
||||
|
||||
it('returns empty string with no args', () => {
|
||||
expect(cn()).toBe('')
|
||||
})
|
||||
|
||||
it('handles nested arrays', () => {
|
||||
expect(cn(['a', ['b', 'c']])).toBe('a b c')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user