Skip to content

Commit b89e6d3

Browse files
feat(content-picker): migrate selectionCellRenderer test to RTL
Co-Authored-By: Joseph Gross <joseph@cognition.ai>
1 parent 1f2f468 commit b89e6d3

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { shallow } from 'enzyme';
2+
import { render, screen } from '../../../test-utils/testing-library';
33
import selectionCellRenderer from '../selectionCellRenderer';
44

55
const rowData = {
@@ -10,22 +10,24 @@ const rowData = {
1010

1111
describe('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

Comments
 (0)