import { describe, test, expect, vi } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import { ChatHeader } from './chat-header'

describe('ChatHeader', () => {
  test('renders title', () => {
    render(<ChatHeader title='Chat Assistant' />)
    expect(screen.getByText('Chat Assistant')).toBeTruthy()
  })

  test('renders close button when onClose provided', () => {
    const onClose = vi.fn()
    render(<ChatHeader title='Test' onClose={onClose} />)
    const closeButton = screen.getByLabelText('Close')
    fireEvent.click(closeButton)
    expect(onClose).toHaveBeenCalledTimes(1)
  })

  test('renders rightSlot', () => {
    render(<ChatHeader title='Test' rightSlot={<button>Custom</button>} />)
    expect(screen.getByText('Custom')).toBeTruthy()
  })

  test('renders leftSlot', () => {
    render(<ChatHeader title='Test' leftSlot={<button>Back</button>} />)
    expect(screen.getByText('Back')).toBeTruthy()
  })
})
