import React from 'react';
import { shallow } from 'enzyme';

import Table from '.';

describe('Table', () => {
  it('displays a data table', () => {
    const mock = {
      head: [['Col 1', 'Col 2', 'Col 3']],
      body: [
        ['A1', 'A2', 'A3'],
        ['B1', 'B2', 'B3'],
        ['C1', 'C2', 'C3'],
      ],
      align: ['left', 'center', 'right'],
    };
    const node = shallow(<Table {...mock} />);
    expect(node.hasClass('Table')).toBe(true);
  });

  it('can specify header colspans', () => {
    const mock = {
      head: [[['Col 1:2', 2], 'Col 3']],
      body: [
        ['A1', 'A2', 'A3'],
        ['B1', 'B2', 'B3'],
        ['C1', 'C2', 'C3'],
      ],
      align: ['left', 'center', 'right'],
    };
    const node = shallow(<Table {...mock} />);
    expect(node.find('[colSpan]')).toHaveLength(1);
  });
});
