import * as renderer from 'react-test-renderer'
import * as React from "react"
import Icon from '../icon'
import {mount} from 'enzyme'

describe('Icon', () => {
  it('render without error', () => {
    const json = renderer.create(<Icon name="car"/>).toJSON();
    expect(json).toMatchSnapshot();
  });
  it('can handle events, and called once', () => {
    const fn = jest.fn();
    const ZIcon = mount(<Icon name="car" onClick={fn}/>);
    ZIcon.find('svg').simulate('click');
    expect(fn.mock.calls.length).toBe(1);
  })
});
