import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { EmptyState } from '../empty-state';

describe('EmptyState', () => {
  it('renders title', () => {
    render(<EmptyState title="Không có dữ liệu" />);
    expect(screen.getByText('Không có dữ liệu')).toBeInTheDocument();
  });

  it('renders description when provided', () => {
    render(<EmptyState title="Title" description="Mô tả phụ" />);
    expect(screen.getByText('Mô tả phụ')).toBeInTheDocument();
  });

  it('does not render description when omitted', () => {
    render(<EmptyState title="Title" />);
    expect(screen.queryByText('Mô tả phụ')).not.toBeInTheDocument();
  });

  it('renders icon node', () => {
    render(<EmptyState title="Title" icon={<span data-testid="icon" />} />);
    expect(screen.getByTestId('icon')).toBeInTheDocument();
  });

  it('renders action node', () => {
    render(
      <EmptyState
        title="Title"
        action={<button data-testid="action">Thêm mới</button>}
      />,
    );
    expect(screen.getByTestId('action')).toBeInTheDocument();
  });

  it('merges custom className', () => {
    render(<EmptyState data-testid="es" title="T" className="custom" />);
    expect(screen.getByTestId('es')).toHaveClass('custom');
  });
});
