import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it } from 'vitest';
import { Textarea } from '../textarea';

describe('Textarea', () => {
  it('renders a textarea element', () => {
    render(<Textarea placeholder="Mô tả" />);
    expect(screen.getByPlaceholderText('Mô tả')).toBeInTheDocument();
  });

  it('accepts typed input', async () => {
    render(<Textarea placeholder="Nhập nội dung" />);
    const textarea = screen.getByPlaceholderText('Nhập nội dung');
    await userEvent.type(textarea, 'Test content');
    expect(textarea).toHaveValue('Test content');
  });

  it('is disabled when disabled prop is set', () => {
    render(<Textarea disabled placeholder="Disabled" />);
    expect(screen.getByPlaceholderText('Disabled')).toBeDisabled();
  });

  it('applies custom className', () => {
    render(<Textarea className="tall" placeholder="Custom" />);
    expect(screen.getByPlaceholderText('Custom')).toHaveClass('tall');
  });
});
