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

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

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

  it('has a role list', () => {
    expect(wrapper.find('View').find({ accessibilityRole: 'list' })).toExist();
  });

  it('has list items', () => {
    wrapper.setProps({
      children: [
        <ListItem primaryText="item 1" />,
        <ListItem primaryText="item 2" />,
      ],
    });
    expect(wrapper.find('ListItem')).toHaveLength(2);
  });

  it('only has items', () => {
    wrapper.setProps({
      children: [
        <ListItem primaryText="item 1" />,
        <div>not an item</div>,
      ],
    });
    expect(wrapper.find('div')).not.toExist();
  });

  it('can be dense', () => {
    wrapper.setProps({
      dense: true,
      children: [<ListItem primaryText="item 1" />],
    });
    expect(wrapper.find('ListItem')).toHaveProp('dense', true);
  });
});
