File tree Expand file tree Collapse file tree
src/components/basic_table Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 */
88
99import React from 'react' ;
10+ import { act } from '@testing-library/react' ;
1011import { render , screen } from '../../test/rtl' ;
1112import { requiredProps } from '../../test' ;
1213import { shouldRenderCustomStyles } from '../../test/internal' ;
@@ -459,6 +460,34 @@ describe('EuiBasicTable', () => {
459460 expect ( onSelectionChange ) . toHaveBeenCalledWith ( [ ] ) ;
460461 expect ( container . querySelectorAll ( '[checked]' ) ) . toHaveLength ( 0 ) ;
461462 } ) ;
463+
464+ // TODO: Delete this test once deprecated API is removed
465+ test ( 'deprecated setSelection ref API' , ( ) => {
466+ const props = {
467+ items : basicItems ,
468+ columns : basicColumns ,
469+ itemId : 'id' ,
470+ selection : {
471+ onSelectionChange : ( ) => { } ,
472+ } ,
473+ } ;
474+
475+ let classRef : EuiBasicTable | null ;
476+ render (
477+ < EuiBasicTable
478+ { ...props }
479+ ref = { ( ref ) => {
480+ classRef = ref ;
481+ } }
482+ />
483+ ) ;
484+ expect ( getCheckboxAt ( 1 ) . checked ) . toBeFalsy ( ) ;
485+
486+ act ( ( ) => {
487+ classRef ! . setSelection ( [ basicItems [ 0 ] ] ) ;
488+ } ) ;
489+ expect ( getCheckboxAt ( 1 ) . checked ) . toBeTruthy ( ) ;
490+ } ) ;
462491 } ) ;
463492
464493 test ( 'footers' , ( ) => {
You can’t perform that action at this time.
0 commit comments