import { render, screen } from '@testing-library/react' import { CommandGroup } from '../CommandGroup' describe('CommandGroup', () => { describe('label', () => { it('renders the provided label text', () => { render(
) expect(screen.getByText('Navigation')).toBeInTheDocument() }) it('renders label in uppercase via CSS class', () => { render(
) const label = screen.getByText('Actions') expect(label.className).toMatch(/uppercase/) }) it('applies text-xs styling to the label', () => { render(
) const label = screen.getByText('Recent') expect(label.className).toMatch(/text-xs/) }) }) describe('children', () => { it('renders children inside the fragment', () => { render(
Item A
) expect(screen.getByTestId('child-item')).toBeInTheDocument() }) it('renders multiple children', () => { render(
One
Two
Three
) expect(screen.getByTestId('item-1')).toBeInTheDocument() expect(screen.getByTestId('item-2')).toBeInTheDocument() expect(screen.getByTestId('item-3')).toBeInTheDocument() }) }) describe('showBorder prop', () => { it('does not add border class by default', () => { const { container } = render(
) const header = container.querySelector('.px-3.py-2') expect(header?.className).not.toMatch(/border-t/) }) it('does not add border class when showBorder is false', () => { const { container } = render(
) const header = container.querySelector('.px-3.py-2') expect(header?.className).not.toMatch(/border-t/) }) it('adds border-t class when showBorder is true', () => { const { container } = render(
) const header = container.querySelector('.px-3.py-2') expect(header?.className).toMatch(/border-t/) }) it('adds border-gray-100 class when showBorder is true', () => { const { container } = render(
) const header = container.querySelector('.px-3.py-2') expect(header?.className).toMatch(/border-gray-100/) }) }) })