import { act, render } from '@testing-library/react';
import React from 'react';
import Table from '.';

const columns = [
  {
    accessor: 'foo',
    header: 'Foo',
  },
  {
    accessor: 'bar',
    header: 'Bar',
  },
];

const data = [
  {
    foo: 'Yolo',
    bar: 'Swag',
  },
];

describe('<Table />', () => {
  it('renders data', () => {
    let result;
    act(() => {
      result = render(<Table keyField="foo" data={data} columns={columns} />);
    });

    expect(result.container).toMatchSnapshot();
  });

  it('renders an empty state', () => {
    const { getByText } = render(
      <Table keyField="foo" data={[]} columns={columns} noDataIndication="No data" />,
    );
    getByText('No data');
  });
});
