import { mount } from 'enzyme';
import ReactDOM from 'react-dom';

import withNextPortal from './withNextPortal';

jest.mock('react-dom');

describe('withNextPortal', () => {
  it('should return a function', () => {
    expect(typeof withNextPortal()).toBe('function');
  });

  it('should create a portal with the component', () => {
    ReactDOM.createPortal.mockImplementation(() => null);
    const props = {};
    const Component = withNextPortal(AnyComponent);
    mount(<Component {...props} />);
    expect(ReactDOM.createPortal).toHaveBeenCalledTimes(1);
  });

  const AnyComponent = () => <div>Test div</div>;
});
