/* eslint-env jest */
import React from 'react';
import { render, mount } from 'enzyme';
import InformationTag from './InformationTag';
import Popover from '@material-ui/core/Popover';

it('renders correctly', () => {
    const tree = render(<InformationTag infoText="text_content" />);
    expect(tree).toMatchSnapshot();
});

it('opens popover onClick of info button', () => {
    const tree = mount(<InformationTag infoText="text_content" />);
    const buttonWrapper = tree.find('button');
    const buttonElement = buttonWrapper.getDOMNode();
    const event = { target: buttonElement };
    buttonWrapper.get(0).props.onClick(event);
    tree.update();
    const popoverProps = tree.find(Popover).props();
    expect(popoverProps.anchorEl).toEqual(buttonElement);
    expect(popoverProps.open).toEqual(true);
});
