1
- /* eslint-disable indent */
1
+ /* eslint-env mocha */
2
+ /* eslint-disable prefer-arrow-callback */
2
3
3
4
import React from 'react' ;
4
5
import ReactDOM from 'react-dom' ;
@@ -9,11 +10,12 @@ import chai from 'chai';
9
10
import DataTable from '../../components/data-table' ;
10
11
import DataTableColumn from '../../components/data-table/column' ;
11
12
import DataTableRowActions from '../../components/data-table/row-actions' ;
13
+ import DataTableHighlightCell from '../../components/data-table/highlight-cell' ;
12
14
13
15
chai . should ( ) ;
14
16
15
17
const { Simulate,
16
- scryRenderedComponentsWithType,
18
+ scryRenderedComponentsWithType,
17
19
findRenderedDOMComponentWithClass
18
20
} = TestUtils ;
19
21
@@ -56,12 +58,10 @@ describe('DataTable: ', function () {
56
58
selectRows : true
57
59
} ;
58
60
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 ) ;
65
65
} ;
66
66
67
67
function removeTable ( ) {
@@ -73,7 +73,7 @@ describe('DataTable: ', function () {
73
73
74
74
const getRow = ( dom , row ) => {
75
75
const tbody = getTable ( dom ) . querySelectorAll ( 'tbody' ) [ 0 ] ;
76
- return tbody . querySelectorAll ( 'tr' ) [ row - 1 ] ;
76
+ return tbody . querySelectorAll ( 'tr' ) [ row - 1 ] ;
77
77
} ;
78
78
79
79
const getCell = ( dom , row , column ) => {
@@ -366,4 +366,27 @@ describe('DataTable: ', function () {
366
366
} , 100 ) ;
367
367
} ) ;
368
368
} ) ;
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
+ } ) ;
369
392
} ) ;
0 commit comments