'use strict';

jest.dontMock('../lib/table.jsx');
jest.dontMock('../lib/cells/index.js');
jest.dontMock('../lib/cells/identity.js');

var React = require('react/addons');
var TestUtils = React.addons.TestUtils;

var Table = require('../lib/table.jsx');


describe('Table', function() {
    it('should render a header based on `header` fields', function() {
        var columns = [
            {
                property: 'name',
                header: 'Name',
            },
            {
                property: 'position',
                header: 'Position',
            },
            {
                property: 'age',
                header: 'Age',
            },
        ];
        var table = TestUtils.renderIntoDocument(
            <Table columns={columns} />
        );

        var ths = TestUtils.scryRenderedDOMComponentsWithTag(
            table, 'th');

        expect(ths.length).toEqual(columns.length);
    });

    it('should render content based on data', function() {
        var columns = [
            {
                property: 'name',
                header: 'Name',
            },
            {
                property: 'position',
                header: 'Position',
            },
            {
                property: 'age',
                header: 'Age',
            },
        ];
        var data = [
            {name: 'foo'},
            {position: 'demo'},
            {age: 123}
        ];
        var table = TestUtils.renderIntoDocument(
            <Table columns={columns} data={data} />
        );

        var trs = TestUtils.scryRenderedDOMComponentsWithTag(
            table, 'tr');

        expect(trs.length).toEqual(data.length + 1);
    });
});

@@ -248,16 +248,231 @@
 sx');%0A%0A%0A
+var Footer = React.createClass(%7B%0A    displayName: 'Footer',%0A    render() %7B%0A        return (%0A            %3Ctfoot%3E%0A                %3Ctr%3EDancing is the poetry of the foot.%3C/tr%3E%0A            %3C/tfoot%3E%0A        );%0A    %7D%0A%7D);%0A%0A
 describe
@@ -1905,13 +1905,620 @@
 %0A    %7D);
+%0A%0A    it('should render correctly with no properties', function() %7B%0A        var renderedTable = TestUtils.renderIntoDocument(%0A            %3CTable/%3E%0A        );%0A%0A        expect(renderedTable.props.data).toEqual(%5B%5D);%0A        expect(renderedTable.props.columns).toEqual(%5B%5D);%0A        expect(renderedTable.props.header).toEqual(%7B%7D);%0A    %7D);%0A%0A    it('should render children correctly', function() %7B%0A        var renderedTable = TestUtils.renderIntoDocument(%0A            %3CTable%3E%0A                %3CFooter/%3E%0A            %3C/Table%3E%0A        );%0A%0A        TestUtils.findRenderedComponentWithType(renderedTable, Footer);%0A    %7D);
 %0A%7D);%0A

Add some tests for the Table component