@@ -230,7 +230,38 @@ See below for the full definition of the `User` object.
230230
231231### Patterns
232232
233- <ExampleSwitcher type = { null } examples = { [' ComboBox' , ' GridList' , ' ListBox' , ' Menu' , ' Select' , ' Table' , ' Tabs' , ' Tree' ]} >
233+ <ExampleSwitcher type = { null } examples = { [' CheckboxGroup' , ' ComboBox' , ' Dialog' , ' GridList' , ' ListBox' , ' Menu' , ' RadioGroup' , ' Select' , ' Table' , ' Tabs' , ' Tree' ]} >
234+
235+ <>
236+ ``` ts isInSwitcher
237+ // CheckboxGroup.test.ts
238+ import {render } from ' @testing-library/react' ;
239+ import {User } from ' @react-aria/test-utils' ;
240+
241+ let testUtilUser = new User ({interactionType: ' mouse' , advanceTimer: jest .advanceTimersByTime });
242+ // ...
243+
244+ it (' CheckboxGroup can select multiple checkboxes' , async function () {
245+ // Render your test component/app and initialize the checkbox group tester
246+ let {getByTestId} = render (
247+ < CheckboxGroup data - testid = " test-checkboxgroup" >
248+ ...
249+ < / CheckboxGroup >
250+ );
251+ let checkboxGroupTester = testUtilUser .createTester (' CheckboxGroup' , {root: getByTestId (' test-checkboxgroup' )});
252+ expect (checkboxGroupTester .selectedCheckboxes ).toHaveLength (0 );
253+
254+ await checkboxGroupTester .toggleCheckbox ({checkbox: 0 });
255+ expect (checkboxGroupTester .checkboxes [0 ]).toBeChecked ();
256+ expect (checkboxGroupTester .selectedCheckboxes ).toHaveLength (1 );
257+
258+ await checkboxGroupTester .toggleCheckbox ({checkbox: 4 });
259+ expect (checkboxGroupTester .checkboxes [4 ]).toBeChecked ();
260+ expect (checkboxGroupTester .selectedCheckboxes ).toHaveLength (2 );
261+ });
262+ ```
263+ <ClassAPI links = { testUtilDocs .links } class = { testUtilDocs .exports .CheckboxGroupTester } isInSwitcher />
264+ </>
234265
235266<>
236267 ``` ts isInSwitcher
@@ -262,6 +293,39 @@ See below for the full definition of the `User` object.
262293 <ClassAPI links = { testUtilDocs .links } class = { testUtilDocs .exports .ComboBoxTester } isInSwitcher />
263294</>
264295
296+ <>
297+ ``` ts isInSwitcher
298+ // Dialog.test.ts
299+ import {render } from ' @testing-library/react' ;
300+ import {User } from ' @react-aria/test-utils' ;
301+
302+ let testUtilUser = new User ({interactionType: ' mouse' , advanceTimer: jest .advanceTimersByTime });
303+ // ...
304+
305+ it (' Dialog can be opened and closed' , async function () {
306+ // Render your test component/app and initialize the dialog tester
307+ let {getByTestId, getByRole} = render (
308+ <DialogTrigger >
309+ <Button >Trigger < / Button >
310+ <Modal >
311+ < Dialog role = " alertdialog" data - testid = " test-dialog" >
312+ ...
313+ < / Dialog >
314+ < / Modal >
315+ < / DialogTrigger >
316+ );
317+ let button = getByRole (' button' );
318+ let dialogTester = testUtilUser .createTester (' Dialog' , {root: button , overlayType: ' modal' });
319+ await dialogTester .open ();
320+ let dialog = dialogTester .dialog ;
321+ expect (dialog ).toHaveAttribute (' role' , ' alertdialog' );
322+ await dialogTester .close ();
323+ expect (dialog ).not .toBeInTheDocument ();
324+ });
325+ ```
326+ <ClassAPI links = { testUtilDocs .links } class = { testUtilDocs .exports .DialogTester } isInSwitcher />
327+ </>
328+
265329<>
266330 ``` ts isInSwitcher
267331 // GridList.test.ts
@@ -356,6 +420,37 @@ See below for the full definition of the `User` object.
356420 <ClassAPI links = { testUtilDocs .links } class = { testUtilDocs .exports .MenuTester } isInSwitcher />
357421</>
358422
423+ <>
424+ ``` ts isInSwitcher
425+ // RadioGroup.test.ts
426+ import {render } from ' @testing-library/react' ;
427+ import {User } from ' @react-aria/test-utils' ;
428+
429+ let testUtilUser = new User ({interactionType: ' mouse' , advanceTimer: jest .advanceTimersByTime });
430+ // ...
431+
432+ it (' RadioGroup can switch the selected radio' , async function () {
433+ // Render your test component/app and initialize the radiogroup tester
434+ let {getByRole} = render (
435+ <RadioGroup >
436+ ...
437+ < / RadioGroup >
438+ );
439+
440+ let radioGroupTester = testUtilUser .createTester (' RadioGroup' , {root: getByRole (' radiogroup' )});
441+ let radios = radioGroupTester .radios ;
442+ expect (radioGroupTester .selectedRadio ).toBeFalsy ();
443+
444+ await radioGroupTester .triggerRadio ({radio: radios [0 ]});
445+ expect (radioGroupTester .selectedRadio ).toBe (radios [0 ]);
446+
447+ await radioGroupTester .triggerRadio ({radio: radios [1 ]});
448+ expect (radioGroupTester .selectedRadio ).toBe (radios [1 ]);
449+ });
450+ ```
451+ <ClassAPI links = { testUtilDocs .links } class = { testUtilDocs .exports .RadioGroupTester } isInSwitcher />
452+ </>
453+
359454<>
360455 ``` ts isInSwitcher
361456 // Select.test.ts
0 commit comments