11import * as React from 'react' ;
2- import { shallow } from 'enzyme ' ;
2+ import { render , screen } from '../../../test-utils/testing-library ' ;
33import selectionCellRenderer from '../selectionCellRenderer' ;
44
55const rowData = {
@@ -10,22 +10,24 @@ const rowData = {
1010
1111describe ( 'selectionCellRenderer' , ( ) => {
1212 test . each ( [
13- [ 'Checkbox' , false ] ,
14- [ 'RadioButton' , true ] ,
15- ] ) ( 'should render %s if isRadio is %s' , ( type , isRadio ) => {
13+ [ true , 'radio' ] ,
14+ [ false , 'checkbox' ] ,
15+ ] ) ( 'should render %s when isRadio is %s' , ( isRadio , expectedRole ) => {
1616 const Element = selectionCellRenderer ( ( ) => { } , 'file, web_link' , [ ] , false , isRadio ) ;
1717
18- const wrapper = shallow ( < Element rowData = { rowData } /> ) ;
19- expect ( wrapper . exists ( type ) ) . toBe ( true ) ;
18+ render ( < Element rowData = { rowData } /> ) ;
19+ expect ( screen . getByRole ( expectedRole ) ) . toBeInTheDocument ( ) ;
2020 } ) ;
2121
2222 test . each ( [
23- [ 'isSelected' , true ] ,
24- [ 'isChecked' , false ] ,
25- ] ) ( 'should render %s if isRadio is %s' , ( type , isRadio ) => {
23+ [ true , 'radio' ] ,
24+ [ false , 'checkbox' ] ,
25+ ] ) ( 'should render %s with correct checked state when isRadio is %s' , ( isRadio , expectedRole ) => {
2626 const Element = selectionCellRenderer ( ( ) => { } , 'file, web_link' , [ ] , false , isRadio ) ;
2727
28- const wrapper = shallow ( < Element rowData = { rowData } /> ) ;
29- expect ( wrapper . prop ( type ) ) . toBe ( true ) ;
28+ render ( < Element rowData = { rowData } /> ) ;
29+ const input = screen . getByRole ( expectedRole ) ;
30+ expect ( input ) . toBeInTheDocument ( ) ;
31+ expect ( input ) . toBeChecked ( ) ;
3032 } ) ;
3133} ) ;
0 commit comments