import React from 'react';
import { assert } from 'chai';
import { mount } from 'enzyme';
import SimpleTable from './SimpleTable';
describe('SimpleTable', () => {
let table: any;
const headers: any = [
one | ];
const rows: any = [
| data |
,
| data |
,
];
const classNameTrue: string = 'test-class';
const classNameFalse: undefined = undefined;
beforeAll(() => {
table = mount();
});
it('renders 3 rows if passed headers and two rows', () => {
assert.equal(table.find('tr').length, 3);
});
it('renders no result message when rows is empty array', () => {
table.setProps({ rows: [] });
assert.isTrue(
table.containsMatchingElement(
There are no results. |
)
);
table.setProps({ rows: [], noRowsText: 'Hello there!!!!' });
assert.isTrue(
table.containsMatchingElement(Hello there!!!! | )
);
});
it('has class name of className prop if provided', () => {
assert.isTrue(
mount(
).hasClass('test-class')
);
});
it("does not have class name of 'undefined' if className prop is undefined", () => {
assert.isFalse(
mount(
).hasClass('undefined')
);
});
});