@@ -4,6 +4,8 @@ import '@testing-library/jest-dom/extend-expect';
4
4
import userEvent from '@testing-library/user-event' ;
5
5
import SelectableBox from '..' ;
6
6
7
+ const boxText = ( text ) => `SelectableBox${ text } ` ;
8
+
7
9
const checkboxType = 'checkbox' ;
8
10
const checkboxText = ( text ) => `SelectableCheckbox${ text } ` ;
9
11
@@ -12,6 +14,16 @@ const radioText = (text) => `SelectableRadio${text}`;
12
14
13
15
const ariaLabel = 'test-default-label' ;
14
16
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
+
15
27
function SelectableCheckboxSet ( props ) {
16
28
return (
17
29
< SelectableBox . Set name = { radioType } type = { checkboxType } ariaLabel = { ariaLabel } { ...props } >
@@ -68,11 +80,8 @@ describe('<SelectableBox.Set />', () => {
68
80
expect ( screen . getByTestId ( 'checkbox-set' ) ) . toBeInTheDocument ( ) ;
69
81
} ) ;
70
82
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" /> ) ;
74
84
expect ( screen . getByTestId ( 'radio-set' ) ) . toBeInTheDocument ( ) ;
75
- console . error = originalError ;
76
85
} ) ;
77
86
it ( 'renders with radio type' , ( ) => {
78
87
render ( < SelectableRadioSet type = { radioType } data-testid = "radio-set" /> ) ;
0 commit comments