@@ -5,7 +5,7 @@ import * as renderer from 'react-test-renderer';
5
5
6
6
import { ChoiceGroup } from './ChoiceGroup' ;
7
7
import { merge , resetIds } from '../../Utilities' ;
8
- import { mountAttached } from '../../common/testUtilities ' ;
8
+ import { safeMount } from '@fluentui/test-utilities ' ;
9
9
import { isConformant } from '../../common/isConformant' ;
10
10
import type { IChoiceGroupOption , IChoiceGroup , IChoiceGroupProps } from './ChoiceGroup.types' ;
11
11
@@ -253,30 +253,34 @@ describe('ChoiceGroup', () => {
253
253
it ( 'can focus the checked option' , ( ) => {
254
254
// This test has to mount the element to the document since ChoiceGroup.focus() uses document.getElementById()
255
255
const choiceGroupRef = React . createRef < IChoiceGroup > ( ) ;
256
- choiceGroup = mountAttached (
256
+ safeMount (
257
257
< ChoiceGroup options = { TEST_OPTIONS } defaultSelectedKey = "1" componentRef = { choiceGroupRef } /> ,
258
+ choiceGroup2 => {
259
+ const option = choiceGroup2 . getDOMNode ( ) . querySelector ( CHOICE_QUERY_SELECTOR ) as HTMLInputElement ;
260
+ const focusSpy = jest . spyOn ( option , 'focus' ) ;
261
+
262
+ choiceGroupRef . current ! . focus ( ) ;
263
+ expect ( focusSpy ) . toHaveBeenCalled ( ) ;
264
+ } ,
265
+ true /* attach */ ,
258
266
) ;
259
-
260
- const option = choiceGroup . getDOMNode ( ) . querySelector ( CHOICE_QUERY_SELECTOR ) as HTMLInputElement ;
261
- const focusSpy = jest . spyOn ( option , 'focus' ) ;
262
-
263
- choiceGroupRef . current ! . focus ( ) ;
264
- expect ( focusSpy ) . toHaveBeenCalled ( ) ;
265
267
} ) ;
266
268
267
269
it ( 'can focus the first enabled option' , ( ) => {
268
270
const choiceGroupRef = React . createRef < IChoiceGroup > ( ) ;
269
- choiceGroup = mountAttached (
271
+ safeMount (
270
272
< ChoiceGroup
271
273
options = { [ { key : '0' , text : 'disabled' , disabled : true } , ...TEST_OPTIONS ] }
272
274
componentRef = { choiceGroupRef }
273
275
/> ,
276
+ choiceGroup2 => {
277
+ const option = choiceGroup2 . getDOMNode ( ) . querySelectorAll ( CHOICE_QUERY_SELECTOR ) ! [ 1 ] as HTMLInputElement ;
278
+ const focusSpy = jest . spyOn ( option , 'focus' ) ;
279
+
280
+ choiceGroupRef . current ! . focus ( ) ;
281
+ expect ( focusSpy ) . toHaveBeenCalled ( ) ;
282
+ } ,
283
+ true /* attach */ ,
274
284
) ;
275
-
276
- const option = choiceGroup . getDOMNode ( ) . querySelectorAll ( CHOICE_QUERY_SELECTOR ) ! [ 1 ] as HTMLInputElement ;
277
- const focusSpy = jest . spyOn ( option , 'focus' ) ;
278
-
279
- choiceGroupRef . current ! . focus ( ) ;
280
- expect ( focusSpy ) . toHaveBeenCalled ( ) ;
281
285
} ) ;
282
286
} ) ;
0 commit comments