import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { SendButton } from './SendButton'

test('renders a button with the specified text and calls the onClick handler when clicked', () => {
  const mockClickHandler = jest.fn()
  render(<SendButton onClick={mockClickHandler} buttonText='Test button' />)

  const sendButton = screen.getByRole('button', { name: 'Test button' })
  expect(sendButton).toBeInTheDocument()
  userEvent.click(sendButton)
  expect(mockClickHandler).toHaveBeenCalledTimes(1)
})

test('renders a disabled button whe the disabled property is set', () => {
  render(<SendButton onClick={jest.fn()} disabled={true} />)

  expect(screen.getByRole('button', { name: 'Send' })).toBeDisabled()
})
