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

describe('ChatStarter', () => {
  const defaultItems = ['Suggestion 1', 'Suggestion 2']

  test('renders title and description', () => {
    render(
      <ChatStarter
        title='Welcome'
        description='How can I help?'
        items={defaultItems}
      />,
    )
    expect(screen.getByText('Welcome')).toBeTruthy()
    expect(screen.getByText('How can I help?')).toBeTruthy()
  })

  test('renders suggestion items', () => {
    render(<ChatStarter items={defaultItems} />)
    expect(screen.getByText('Suggestion 1')).toBeTruthy()
    expect(screen.getByText('Suggestion 2')).toBeTruthy()
  })

  test('calls item onClick when clicked', () => {
    const onSelect = vi.fn()
    render(<ChatStarter items={defaultItems} onSelect={onSelect} />)
    fireEvent.click(screen.getByText('Suggestion 1'))
    expect(onSelect).toHaveBeenCalledTimes(1)
  })
})
