import { render } from '@testing-library/react';
import React from 'react';
import { describe, expect, it } from 'vitest';
import { Data } from '../../../../../types/data';
import { BooleanDotRenderer } from './BooleanDotRenderer';

interface RendererWrapperProps {
  /** Column data */
  value: unknown;
  /** Row data */
  data: Data;
}

const RendererWrapper: React.FC<RendererWrapperProps> = ({ value }) => {
  return <>{BooleanDotRenderer(value)}</>;
};

const defaultProps: RendererWrapperProps = {
  value: '',
  data: {},
};

describe('BooleanDotRenderer', () => {
  it('renders the component without crashing', () => {
    const { container } = render(<RendererWrapper {...defaultProps} />);
    expect(container).toBeTruthy();
  });

  it('renders the red dot when false is passed', () => {
    const { container } = render(
      <RendererWrapper {...defaultProps} value={false} />,
    );
    const dot = container.querySelector('.false');
    expect(dot).toBeInTheDocument();
  });

  it('renders the green dot when true is passed', () => {
    const { container } = render(
      <RendererWrapper {...defaultProps} value={true} />,
    );
    const dot = container.querySelector('.true');
    expect(dot).toBeInTheDocument();
  });
});
