/* eslint-env jest */
import React from 'react';
import noop from 'lodash/noop';
import mount from 'enzyme/mount';
import render from 'enzyme/render';
import AddVisualElement from './index';

jest.mock('App/Shared/Components/CallToAction', () => {
    return {
        __esModule: true,
        default: () => {
            return <div />;
        },
    };
});

it('renders correctly', () => {
    const tree = render(<AddVisualElement onImageFileSelected={noop} onAddTextClick={noop} />);
    expect(tree).toMatchSnapshot();
});

it('renders a boxed component with the boxed prop', () => {
    const tree = render(<AddVisualElement onImageFileSelected={noop} onAddTextClick={noop} boxed />);
    expect(tree).toMatchSnapshot();
});

it('calls the onImageFileSelected callback when the user clicks the onImageFileSelected button', () => {
    const spy = jest.fn();
    const tree = mount(<AddVisualElement onImageFileSelected={spy} onAddTextClick={noop} />);
    tree.find('button')
        .at(0)
        .find('input')
        .simulate('change', { value: '' });
    expect(spy).toHaveBeenCalled();
});
