@@ -289,29 +289,54 @@ describe('AnalyticalTable', () => {
289
289
const UsingTable = ( props ) => {
290
290
tableRef = useRef ( null ) ;
291
291
return (
292
- < AnalyticalTable ref = { tableRef } title = "Table Title" data = { data } columns = { columns } visibleRows = { 1 } minRows = { 1 } />
292
+ < AnalyticalTable
293
+ style = { { width : '170px' } }
294
+ ref = { tableRef }
295
+ title = "Table Title"
296
+ data = { data }
297
+ columns = { columns }
298
+ visibleRows = { 1 }
299
+ minRows = { 1 }
300
+ />
293
301
) ;
294
302
} ;
295
303
296
- render ( < UsingTable /> ) ;
304
+ const { getByRole , container } = render ( < UsingTable /> ) ;
297
305
298
306
// Check existence + type
299
307
expect ( typeof tableRef . current . scrollTo ) . toBe ( 'function' ) ;
300
308
expect ( typeof tableRef . current . scrollToItem ) . toBe ( 'function' ) ;
309
+ expect ( typeof tableRef . current . horizontalScrollTo ) . toBe ( 'function' ) ;
310
+ expect ( typeof tableRef . current . horizontalScrollToItem ) . toBe ( 'function' ) ;
301
311
302
312
// call functions
303
- const tableInnerRef = tableRef . current . querySelector ( "div[class^='AnalyticalTable-table'] > div" ) ;
313
+ const tableBodyRef = tableRef . current . querySelector ( "div[class^='AnalyticalTable-tbody']" ) ;
314
+ const tableContainerRef = getByRole ( 'grid' , { hidden : true } ) ;
315
+
304
316
act ( ( ) => {
305
317
tableRef . current . scrollToItem ( 1 , 'start' ) ;
306
318
} ) ;
307
319
308
- expect ( tableInnerRef . scrollTop ) . toBe ( 44 ) ;
320
+ expect ( tableBodyRef . scrollTop ) . toBe ( 44 ) ;
309
321
310
322
act ( ( ) => {
311
323
tableRef . current . scrollTo ( 2 ) ;
312
324
} ) ;
313
325
314
- expect ( tableInnerRef . scrollTop ) . toBe ( 2 ) ;
326
+ expect ( tableBodyRef . scrollTop ) . toBe ( 2 ) ;
327
+
328
+ screen . debug ( tableContainerRef , 9999999 ) ;
329
+ act ( ( ) => {
330
+ tableRef . current . horizontalScrollToItem ( 1 , 'start' ) ;
331
+ } ) ;
332
+
333
+ expect ( tableContainerRef . scrollLeft ) . toBe ( 150 ) ;
334
+
335
+ act ( ( ) => {
336
+ tableRef . current . horizontalScrollTo ( 2 ) ;
337
+ } ) ;
338
+
339
+ expect ( tableContainerRef . scrollLeft ) . toBe ( 2 ) ;
315
340
} ) ;
316
341
317
342
test ( 'with highlight row' , ( ) => {
0 commit comments