import { render, screen } from '@testing-library/react';
import { ThemeProvider } from '../../../theme';
import EmptyState from './EmptyState';

describe('<EmptyState/>', () => {
  const wrap = (ui: React.ReactNode) => render(<ThemeProvider>{ui}</ThemeProvider>);

  it('renders the title and body', () => {
    wrap(<EmptyState title="Nothing here" body="Add your first patient" />);
    expect(screen.getByText('Nothing here')).toBeInTheDocument();
    expect(screen.getByText('Add your first patient')).toBeInTheDocument();
  });

  it('omits the body when not given', () => {
    wrap(<EmptyState title="Empty" />);
    expect(screen.getByText('Empty')).toBeInTheDocument();
  });

  it('renders the action slot when provided', () => {
    wrap(<EmptyState title="Empty" action={<button>Add</button>} />);
    expect(screen.getByRole('button', { name: 'Add' })).toBeInTheDocument();
  });
});
