Skip to content
This repository was archived by the owner on Jan 15, 2022. It is now read-only.

Commit b8a5c5e

Browse files
committed
added failing test for rendering sub components
1 parent 3cb876f commit b8a5c5e

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tests/reactable_test.jsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,63 @@ describe('Reactable', function() {
417417
});
418418
});
419419

420+
describe('adding <CustomComponents>s to the <Table>', function() {
421+
before(function() {
422+
var CustomComponent = React.createClass({
423+
displayName: "CustomComponent",
424+
propTypes:{
425+
name: React.PropTypes.string,
426+
age: React.PropTypes.number,
427+
position: React.PropTypes.string
428+
},
429+
render: function(){
430+
return (
431+
<Reactable.Tr>
432+
<Reactable.Td column="Name">{this.props.name}</Reactable.Td>
433+
<Reactable.Td column="Age">{this.props.age}</Reactable.Td>
434+
<Reactable.Td column="Position">{this.props.position}</Reactable.Td>
435+
</Reactable.Tr>
436+
);
437+
}
438+
});
439+
React.render(
440+
<Reactable.Table className="table" id="table">
441+
<CustomComponent name='Griffin Smith' age={18} />
442+
<CustomComponent name='Lee Salminen' age={23} />
443+
<CustomComponent age={28} position='Developer' />
444+
</Reactable.Table>,
445+
ReactableTestUtils.testNode()
446+
);
447+
});
448+
449+
after(ReactableTestUtils.resetTestEnvironment);
450+
451+
it('renders the table', function() {
452+
expect($('table#table.table')).to.exist;
453+
});
454+
455+
it('renders the column headers in the table', function() {
456+
var headers = [];
457+
$('thead th').each(function() {
458+
headers.push($(this).text());
459+
});
460+
461+
expect(headers).to.eql([ 'Name', 'Age', 'Position' ]);
462+
});
463+
464+
it('renders the first row with the correct data', function() {
465+
ReactableTestUtils.expectRowText(0, ['Griffin Smith', '18', '']);
466+
});
467+
468+
it('renders the second row with the correct data', function() {
469+
ReactableTestUtils.expectRowText(1, ['Lee Salminen', '23', '']);
470+
});
471+
472+
it('renders the third row with the correct data', function() {
473+
ReactableTestUtils.expectRowText(2, ['', '28', 'Developer']);
474+
});
475+
});
476+
420477
describe('passing through HTML props', function() {
421478
describe('adding <Tr>s with className to the <Table>', function() {
422479
before(function() {

0 commit comments

Comments
 (0)