import React from 'react';
import { createShallow, createMount } from '@material-ui/core/test-utils';

import FlatListmemo, { FlatList } from './FlatList';

const users = [
  {
    id: 1,
    username: 'admin',
    password: null,
    firstName: 'admin',
    lastName: 'admin',
    email: 'admin@email.com',
    activated: true,
    enabled: true,
    imageUrl: null,
    fullAccess: true
  },
  {
    id: 10,
    username: 'rilevatore',
    password: null,
    firstName: null,
    lastName: null,
    email: 'rilevatore@email.com',
    activated: true,
    enabled: true,
    imageUrl: null,
    fullAccess: true
  }
];

describe('<FlatList />', () => {
  const mount = createMount();
  const shallow = createShallow();

  it('shallow render without crashing', () => {
    const wrapper = shallow(<FlatList items={users} />);
    expect(wrapper).toMatchSnapshot();
  });

  it('mount render without crashing', () => {
    const wrapper = mount(<FlatList items={users} />);
    expect(wrapper).toMatchSnapshot();
  });

  it('shallow render memoized component without crashing', () => {
    const wrapper = shallow(<FlatListmemo items={users} />);
    expect(wrapper).toMatchSnapshot();
  });

  it('mount render memoized component without crashing', () => {
    const wrapper = mount(<FlatListmemo items={users} />);
    expect(wrapper).toMatchSnapshot();
  });
});
