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

describe('ChatSuggestionButton', () => {
  test('renders label text', () => {
    render(<ChatSuggestionButton label='Try this' onClick={vi.fn()} />)
    expect(screen.getByText('Try this')).toBeTruthy()
  })

  test('calls onClick when clicked', () => {
    const onClick = vi.fn()
    render(<ChatSuggestionButton label='Click me' onClick={onClick} />)
    fireEvent.click(screen.getByText('Click me'))
    expect(onClick).toHaveBeenCalledTimes(1)
  })

  test('is disabled when disabled prop is true', () => {
    const onClick = vi.fn()
    render(<ChatSuggestionButton label='Disabled' onClick={onClick} disabled />)
    const button = screen.getByRole('button')
    expect(button.hasAttribute('disabled')).toBeTruthy()
  })
})
