import { describe, test, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import { GroupWrapper } from './group-wrapper'

describe('GroupWrapper', () => {
  const mockTitle = 'Group Title'
  const mockChildContent = 'Child Content'
  const mockChild = <div>{mockChildContent}</div>

  test('should render title and children when not collapsed', () => {
    render(
      <GroupWrapper title={mockTitle} collapsed={false}>
        {mockChild}
      </GroupWrapper>,
    )

    expect(screen.getByText(mockTitle)).toBeDefined()
    expect(screen.getByText(mockChildContent)).toBeDefined()
  })

  test('should only render children when collapsed', () => {
    render(
      <GroupWrapper title={mockTitle} collapsed={true}>
        {mockChild}
      </GroupWrapper>,
    )

    expect(screen.queryByText(mockTitle)).toBeNull()
    expect(screen.getByText(mockChildContent)).toBeDefined()
  })

  test('should default to not collapsed when collapsed prop is not provided', () => {
    render(<GroupWrapper title={mockTitle}>{mockChild}</GroupWrapper>)

    expect(screen.getByText(mockTitle)).toBeDefined()
    expect(screen.getByText(mockChildContent)).toBeDefined()
  })
})
