import React from 'react';
import ReactDOM from 'react-dom';
import { shallow } from 'enzyme';

import Popover, { PurePopover, BEM } from '../Popover';
import ListSpacingContext from '../contexts/listSpacing';

describe('<Popover> with mixins', () => {
  it('should render without crashing', () => {
    const div = document.createElement('div');
    const element = <Popover />;

    ReactDOM.render(element, div);
  });
});

describe('Pure <Popover>', () => {
  it('provides context for children list spacing', () => {
    const wrapper = shallow(<PurePopover />);

    expect(wrapper.find(ListSpacingContext.Provider).exists()).toBeTruthy();
    expect(wrapper.find(ListSpacingContext.Provider).prop('value')).toBe(false);
  });

  it('renders class names in respond to placement prop', () => {
    const wrapper = shallow(<PurePopover placement="bottom" />);
    expect(wrapper.children('div').hasClass(
      BEM.root
        .modifier('bottom')
        .toString({ stripBlock: true })
    )).toBeTruthy();

    wrapper.setProps({ placement: 'top' });
    expect(wrapper.children('div').hasClass(
      BEM.root
        .modifier('top')
        .toString({ stripBlock: true })
    )).toBeTruthy();
  });

  it('passes arrowStyle prop to arrow node', () => {
    const wrapper = shallow(
      <PurePopover arrowStyle={{ top: 50, left: 100 }} />
    );
    const arrowClassName = BEM.arrow.toString();

    expect(wrapper.find(`.${arrowClassName}`).prop('style'))
      .toMatchObject({
        top: 50,
        left: 100,
      });
  });
});

@@ -1527,21 +1527,852 @@
 %0A      %7D);%0A  %7D);
+%0A%0A  describe('container max height', () =%3E %7B%0A    it('compute maxHeight on vertical placement', () =%3E %7B%0A      const wrapper = shallow(%0A        %3CPurePopover%0A          placement=%22top%22%0A          remainingSpace=%7B50%7D%0A        /%3E%0A      );%0A      const containerClassName = BEM.container.toString();%0A%0A      expect(wrapper.find(%60.$%7BcontainerClassName%7D%60).prop('style'))%0A        .toMatchObject(%7B%0A          maxHeight: 26,%0A        %7D);%0A    %7D);%0A    it('wont compute maxHeight on horizontal placement', () =%3E %7B%0A      const wrapper = shallow(%0A        %3CPurePopover%0A          placement=%22left%22%0A          remainingSpace=%7B50%7D%0A        /%3E%0A      );%0A      const containerClassName = BEM.container.toString();%0A%0A      expect(wrapper.find(%60.$%7BcontainerClassName%7D%60).prop('style'))%0A        .toMatchObject(%7B%0A          maxHeight: undefined,%0A        %7D);%0A    %7D);%0A  %7D);
 %0A%7D);%0A

add popover maxHeight test