Skip to content

Commit 63d4640

Browse files
fix: properly test untyped selectable box sets (#2736)
1 parent 46f8d85 commit 63d4640

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/SelectableBox/tests/SelectableBoxSet.test.jsx

+13-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import '@testing-library/jest-dom/extend-expect';
44
import userEvent from '@testing-library/user-event';
55
import SelectableBox from '..';
66

7+
const boxText = (text) => `SelectableBox${text}`;
8+
79
const checkboxType = 'checkbox';
810
const checkboxText = (text) => `SelectableCheckbox${text}`;
911

@@ -12,6 +14,16 @@ const radioText = (text) => `SelectableRadio${text}`;
1214

1315
const ariaLabel = 'test-default-label';
1416

17+
function SelectableBoxSet(props) {
18+
return (
19+
<SelectableBox.Set name="box" ariaLabel={ariaLabel} {...props}>
20+
<SelectableBox value={1}>{boxText(1)}</SelectableBox>
21+
<SelectableBox value={2}>{boxText(2)}</SelectableBox>
22+
<SelectableBox value={3}>{boxText(3)}</SelectableBox>
23+
</SelectableBox.Set>
24+
);
25+
}
26+
1527
function SelectableCheckboxSet(props) {
1628
return (
1729
<SelectableBox.Set name={radioType} type={checkboxType} ariaLabel={ariaLabel} {...props}>
@@ -68,11 +80,8 @@ describe('<SelectableBox.Set />', () => {
6880
expect(screen.getByTestId('checkbox-set')).toBeInTheDocument();
6981
});
7082
it('renders with radio type if neither checkbox nor radio is passed', () => {
71-
const originalError = console.error;
72-
console.error = jest.fn();
73-
render(<SelectableCheckboxSet type="text" data-testid="radio-set" />);
83+
render(<SelectableBoxSet data-testid="radio-set" />);
7484
expect(screen.getByTestId('radio-set')).toBeInTheDocument();
75-
console.error = originalError;
7685
});
7786
it('renders with radio type', () => {
7887
render(<SelectableRadioSet type={radioType} data-testid="radio-set" />);

0 commit comments

Comments
 (0)