// @flow
import React from 'react';
import { shallow } from 'enzyme';
import ListItemLeft from './ListItemLeft';

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

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

  it('has a container', () => {
    expect(wrapper.find('View')).toExist();
  });

  it('can have an avatar', () => {
    const avatar = { imageUrl: '/test.png', description: 'test' };
    wrapper.setProps({ avatar });
    const avatarElem = wrapper.find('Avatar');
    expect(avatarElem).toExist();
    expect(avatarElem).toHaveProp('imageUrl', avatar.imageUrl);
    expect(avatarElem).toHaveProp('description', avatar.description);
  });

  it('by default does not have an avatar nor an icon', () => {
    expect(wrapper.find('Avatar')).not.toExist();
    expect(wrapper.find('Icon')).not.toExist();
  });

  it('can have an icon', () => {
    const icon = 'email';
    wrapper.setProps({ icon });
    const iconElem = wrapper.find('Icon');
    expect(iconElem).toExist();
    expect(iconElem).toHaveProp('name', 'email');
  });
});
