// @flow
import React from 'react';
import { shallow } from 'enzyme';
// $FlowFixMe
import MaterialIcon from 'react-native-vector-icons/dist/MaterialIcons';
import Icon from './Icon';

jest.mock('react-native-vector-icons/dist/MaterialIcons');

describe('Icon component', () => {
  let wrapper;

  beforeEach(() => {
    wrapper = shallow(<Icon />);
  });

  it('is a material icon', () => {
    expect(wrapper.find(MaterialIcon)).toExist();
  });

  it('needs the name of the icon', () => {
    const name = 'email';
    wrapper.setProps({ name });
    expect(wrapper.find(MaterialIcon)).toHaveProp('name', name);
  });

  it('can have a custom color', () => {
    const color = '#00F';
    wrapper.setProps({ color });
    expect(wrapper.find(MaterialIcon)).toHaveProp('color', color);
  });

  it('has default size', () => {
    expect(wrapper.find(MaterialIcon)).toHaveProp('size', 24);
  });

  it('can have custom size', () => {
    wrapper.setProps({ size: 80 });
    expect(wrapper.find(MaterialIcon)).toHaveProp('size', 80);
  });
});
