/**
 * @ai-summary Tests for EmptyState component
 */

import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import { EmptyState } from '../../components/EmptyState';

describe('EmptyState', () => {
  it('should render with title and description', () => {
    const { container } = render(
      <EmptyState
        title="No Data"
        description="Start by adding your first item"
      />
    );

    expect(container).toMatchSnapshot();
    expect(screen.getByText('No Data')).toBeInTheDocument();
    expect(screen.getByText('Start by adding your first item')).toBeInTheDocument();
  });

  it('should render with icon', () => {
    const { container } = render(
      <EmptyState
        icon={<div data-testid="test-icon">Icon</div>}
        title="Empty"
        description="No items found"
      />
    );

    expect(container).toMatchSnapshot();
    expect(screen.getByTestId('test-icon')).toBeInTheDocument();
  });

  it('should render action button when provided', () => {
    const handleAction = jest.fn();

    render(
      <EmptyState
        title="No Items"
        description="Add your first item"
        action={{ label: 'Add Item', onClick: handleAction }}
      />
    );

    const button = screen.getByText('Add Item');
    expect(button).toBeInTheDocument();

    fireEvent.click(button);
    expect(handleAction).toHaveBeenCalledTimes(1);
  });

  it('should not render action button when not provided', () => {
    render(<EmptyState title="Empty" description="No data" />);

    expect(screen.queryByRole('button')).not.toBeInTheDocument();
  });
});
