Skip to content

Commit 4db225e

Browse files
author
David Brainer-Banker
committed
Add a highlight-cell test to DataTable
1 parent b047c3f commit 4db225e

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

tests/data-table/data-table.test.js

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* eslint-disable indent */
1+
/* eslint-env mocha */
2+
/* eslint-disable prefer-arrow-callback */
23

34
import React from 'react';
45
import ReactDOM from 'react-dom';
@@ -9,11 +10,12 @@ import chai from 'chai';
910
import DataTable from '../../components/data-table';
1011
import DataTableColumn from '../../components/data-table/column';
1112
import DataTableRowActions from '../../components/data-table/row-actions';
13+
import DataTableHighlightCell from '../../components/data-table/highlight-cell';
1214

1315
chai.should();
1416

1517
const { Simulate,
16-
scryRenderedComponentsWithType,
18+
scryRenderedComponentsWithType,
1719
findRenderedDOMComponentWithClass
1820
} = TestUtils;
1921

@@ -56,12 +58,10 @@ describe('DataTable: ', function () {
5658
selectRows: true
5759
};
5860

59-
const renderTable = (instance) => {
60-
return function () {
61-
this.dom = document.createElement('div');
62-
document.body.appendChild(this.dom);
63-
this.component = ReactDOM.render(instance, this.dom);
64-
};
61+
const renderTable = (instance) => function () {
62+
this.dom = document.createElement('div');
63+
document.body.appendChild(this.dom);
64+
this.component = ReactDOM.render(instance, this.dom);
6565
};
6666

6767
function removeTable () {
@@ -73,7 +73,7 @@ describe('DataTable: ', function () {
7373

7474
const getRow = (dom, row) => {
7575
const tbody = getTable(dom).querySelectorAll('tbody')[0];
76-
return tbody.querySelectorAll('tr')[row-1];
76+
return tbody.querySelectorAll('tr')[row - 1];
7777
};
7878

7979
const getCell = (dom, row, column) => {
@@ -366,4 +366,27 @@ describe('DataTable: ', function () {
366366
}, 100);
367367
});
368368
});
369+
370+
describe('w/ HighlightCell', function () {
371+
afterEach(removeTable);
372+
373+
it('marks the appropriate text in a cell', function () {
374+
renderTable(
375+
<DataTable
376+
{...defaultProps}
377+
search="Cloud"
378+
>
379+
{columns.map((columnProps) => (
380+
<DataTableColumn {...columnProps} key={columnProps.property}>
381+
<DataTableHighlightCell />
382+
</DataTableColumn>
383+
))}
384+
</DataTable>
385+
).call(this);
386+
387+
const secondRow = getRow(this.dom, 2);
388+
const markedText = secondRow.querySelectorAll('mark')[0];
389+
markedText.innerHTML.should.equal('Cloud');
390+
});
391+
});
369392
});

0 commit comments

Comments
 (0)