import { render, screen } from '@testing-library/react';
import TableStatusText, { TableStatusTextProps } from './TableStatusText';

describe('TableStatusText Component', () => {
  const renderComponent = (props: Partial<TableStatusTextProps> = {}) => {
    const defaultProps: TableStatusTextProps = {
      text: 'Status Text',
      ...props,
    };
    return render(<TableStatusText {...defaultProps} />);
  };

  it('renders the text and applies the default class', () => {
    renderComponent();
    expect(screen.getByText('Status Text')).toBeInTheDocument();
    expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default');
  });

  it('applies the custom class name', () => {
    renderComponent({ className: 'custom-class' });
    expect(screen.getByText('Status Text')).toHaveClass('custom-class');
  });

  it('applies the default typography class when typography is not provided', () => {
    renderComponent();
    expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default');
  });

  it('applies the typography class when typography equals `default-bold`', () => {
    renderComponent({ typography: 'default-bold' });
    expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default-bold');
  });

  it('does not render any icon when status is not provided', () => {
    renderComponent();
    expect(screen.queryByTestId('check-icon')).not.toBeInTheDocument();
    expect(screen.queryByTestId('alert-icon')).not.toBeInTheDocument();
  });

  it('applies the typography and status classes, renders the error icon when status equals `error`', () => {
    renderComponent({ status: 'error' });
    expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default-bold');
    expect(screen.getByText('Status Text')).toHaveClass('np-table-content--error');
    expect(screen.getByTestId('alert-icon')).toBeInTheDocument();
  });

  it('applies the typography and status classes, renders the success icon when status equals `success`', () => {
    renderComponent({ status: 'success' });
    expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default-bold');
    expect(screen.getByText('Status Text')).toHaveClass('np-table-content--success');
    expect(screen.getByTestId('check-icon')).toBeInTheDocument();
  });
});
