import { cleanup, fireEvent } from '@testing-library/react';
import { render } from '../../utils/theme-render-wrapper';
import { GRID_ROW_HEIGHT } from '../data-grid';
import { TextWithTooltip } from './text-with-tooltip';

afterEach(cleanup);

const text =
  "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s";

describe('<TextWithTooltip />', () => {
  it(`Should render successfully`, () => {
    const { baseElement } = render(<TextWithTooltip text={text} />);
    expect(baseElement).toBeTruthy();
  });

  it(`Should render with alternative title`, () => {
    const { baseElement } = render(
      <TextWithTooltip text={text} title="Alternative title text goes here" numOfLines={1} />
    );
    expect(baseElement).toBeTruthy();
  });

  it(`Should render a comma delimited text`, () => {
    const { getByTestId } = render(
      <TextWithTooltip
        text={text.split('text')}
        textSeparator=", "
        numOfLines={2}
        resizeDebounceTime={-1} // disables debounce
        style={{ maxWidth: 96, maxHeight: GRID_ROW_HEIGHT }}
      />
    );
    const textEl = getByTestId('text');
    fireEvent.mouseOver(textEl);
    expect(textEl).toBeTruthy();
  });
});
