// @flow
import React from 'react';
import { mountWrappedComponent, itIsAccessible } from '../../../../utils/tests';

import type { TooltipProps, ReferenceArgs } from './tooltip.proptypes';
import { Tooltip } from './index';

const REFERENCE_PROPS = {
  ref: () => {},
  referenceProps: {
    onMouseEnter: () => {},
    onMouseLeave: () => {},
    onFocus: () => {},
    onBlur: () => {},
  },
};

const DEFAULT_PROPS: TooltipProps = {
  reference: ({ referenceProps, ref }: ReferenceArgs) => (
    <div {...referenceProps} ref={ref}>
      Reference element
    </div>
  ),
  placement: 'left',
  children: '',
};

describe('Tooltip', () => {
  it('renders the reference element', () => {
    const tooltip = mountWrappedComponent(<Tooltip {...DEFAULT_PROPS} />);
    const referenceElement = tooltip.renderProp('reference')(REFERENCE_PROPS);
    expect(referenceElement.text()).toBe('Reference element');
  });

  itIsAccessible(
    <div>
      <Tooltip isVisible {...DEFAULT_PROPS} />
    </div>,
  );
});
