@@ -202,47 +202,47 @@ describe('<ButtonBase />', () => {
202202 if ( typeof Touch !== 'undefined' ) {
203203 const touch = new Touch ( { identifier : 0 , target : button , clientX : 0 , clientY : 0 } ) ;
204204
205- await act ( async ( ) => fireEvent . touchStart ( button , { touches : [ touch ] } ) ) ;
205+ fireEvent . touchStart ( button , { touches : [ touch ] } ) ;
206206 expect ( onTouchStart . callCount ) . to . equal ( 1 ) ;
207207
208- await act ( async ( ) => fireEvent . touchEnd ( button , { touches : [ touch ] } ) ) ;
208+ fireEvent . touchEnd ( button , { touches : [ touch ] } ) ;
209209 expect ( onTouchEnd . callCount ) . to . equal ( 1 ) ;
210210 }
211211
212212 if ( canFireDragEvents ) {
213- await act ( async ( ) => fireEvent . dragEnd ( button ) ) ;
213+ fireEvent . dragEnd ( button ) ;
214214 expect ( onDragEnd . callCount ) . to . equal ( 1 ) ;
215215 }
216216
217- await act ( async ( ) => fireEvent . mouseDown ( button ) ) ;
217+ fireEvent . mouseDown ( button ) ;
218218 expect ( onMouseDown . callCount ) . to . equal ( 1 ) ;
219219
220- await act ( async ( ) => fireEvent . mouseUp ( button ) ) ;
220+ fireEvent . mouseUp ( button ) ;
221221 expect ( onMouseUp . callCount ) . to . equal ( 1 ) ;
222222
223- await act ( async ( ) => fireEvent . contextMenu ( button ) ) ;
223+ fireEvent . contextMenu ( button ) ;
224224 expect ( onContextMenu . callCount ) . to . equal ( 1 ) ;
225225
226226 await user . click ( button ) ;
227227 expect ( onClick . callCount ) . to . equal ( 1 ) ;
228228
229- act ( ( ) => {
229+ await act ( async ( ) => {
230230 button . focus ( ) ;
231231 } ) ;
232232 expect ( onFocus . callCount ) . to . equal ( 1 ) ;
233233
234- await act ( async ( ) => fireEvent . keyDown ( button ) ) ;
234+ fireEvent . keyDown ( button ) ;
235235 expect ( onKeyDown . callCount ) . to . equal ( 1 ) ;
236236
237- await act ( async ( ) => fireEvent . keyUp ( button ) ) ;
237+ fireEvent . keyUp ( button ) ;
238238 expect ( onKeyUp . callCount ) . to . equal ( 1 ) ;
239239
240- act ( ( ) => {
240+ await act ( async ( ) => {
241241 button . blur ( ) ;
242242 } ) ;
243243 expect ( onBlur . callCount ) . to . equal ( 1 ) ;
244244
245- await act ( async ( ) => fireEvent . mouseLeave ( button ) ) ;
245+ fireEvent . mouseLeave ( button ) ;
246246 expect ( onMouseLeave . callCount ) . to . equal ( 1 ) ;
247247 } ) ;
248248 } ) ;
@@ -942,9 +942,7 @@ describe('<ButtonBase />', () => {
942942
943943 await ripple . startFocus ( button ) ;
944944
945- act ( ( ) => {
946- fireEvent . keyDown ( button , { key : 'Enter' } ) ;
947- } ) ;
945+ fireEvent . keyDown ( button , { key : 'Enter' } ) ;
948946
949947 expect ( container . querySelectorAll ( '.ripple-visible' ) ) . to . have . lengthOf ( 1 ) ;
950948
@@ -1007,7 +1005,7 @@ describe('<ButtonBase />', () => {
10071005 } ) ;
10081006
10091007 describe ( 'keyboard accessibility for non interactive elements' , ( ) => {
1010- it ( 'does not call onClick when a spacebar is pressed on the element but prevents the default' , ( ) => {
1008+ it ( 'does not call onClick when a spacebar is pressed on the element but prevents the default' , async ( ) => {
10111009 const onKeyDown = spy ( ) ;
10121010 const onClickSpy = spy ( ) ;
10131011 const { getByRole } = render (
@@ -1017,19 +1015,20 @@ describe('<ButtonBase />', () => {
10171015 ) ;
10181016 const button = getByRole ( 'button' ) ;
10191017
1020- act ( ( ) => {
1018+ await act ( async ( ) => {
10211019 button . focus ( ) ;
1022- fireEvent . keyDown ( button , {
1023- key : ' ' ,
1024- } ) ;
1020+ } ) ;
1021+
1022+ fireEvent . keyDown ( button , {
1023+ key : ' ' ,
10251024 } ) ;
10261025
10271026 expect ( onClickSpy . callCount ) . to . equal ( 0 ) ;
10281027 expect ( onKeyDown . callCount ) . to . equal ( 1 ) ;
10291028 expect ( onKeyDown . firstCall . args [ 0 ] ) . to . have . property ( 'defaultPrevented' , true ) ;
10301029 } ) ;
10311030
1032- it ( 'does call onClick when a spacebar is released on the element' , ( ) => {
1031+ it ( 'does call onClick when a spacebar is released on the element' , async ( ) => {
10331032 const onClickSpy = spy ( ) ;
10341033 const { getByRole } = render (
10351034 < ButtonBase onClick = { onClickSpy } component = "div" >
@@ -1038,18 +1037,19 @@ describe('<ButtonBase />', () => {
10381037 ) ;
10391038 const button = getByRole ( 'button' ) ;
10401039
1041- act ( ( ) => {
1040+ await act ( async ( ) => {
10421041 button . focus ( ) ;
1043- fireEvent . keyUp ( button , {
1044- key : ' ' ,
1045- } ) ;
1042+ } ) ;
1043+
1044+ fireEvent . keyUp ( button , {
1045+ key : ' ' ,
10461046 } ) ;
10471047
10481048 expect ( onClickSpy . callCount ) . to . equal ( 1 ) ;
10491049 expect ( onClickSpy . firstCall . args [ 0 ] ) . to . have . property ( 'defaultPrevented' , false ) ;
10501050 } ) ;
10511051
1052- it ( 'does not call onClick when a spacebar is released and the default is prevented' , ( ) => {
1052+ it ( 'does not call onClick when a spacebar is released and the default is prevented' , async ( ) => {
10531053 const onClickSpy = spy ( ) ;
10541054 const { getByRole } = render (
10551055 < ButtonBase
@@ -1067,17 +1067,18 @@ describe('<ButtonBase />', () => {
10671067 ) ;
10681068 const button = getByRole ( 'button' ) ;
10691069
1070- act ( ( ) => {
1070+ await act ( async ( ) => {
10711071 button . focus ( ) ;
1072- fireEvent . keyUp ( button , {
1073- key : ' ' ,
1074- } ) ;
1072+ } ) ;
1073+
1074+ fireEvent . keyUp ( button , {
1075+ key : ' ' ,
10751076 } ) ;
10761077
10771078 expect ( onClickSpy . callCount ) . to . equal ( 0 ) ;
10781079 } ) ;
10791080
1080- it ( 'calls onClick when Enter is pressed on the element' , ( ) => {
1081+ it ( 'calls onClick when Enter is pressed on the element' , async ( ) => {
10811082 const onClickSpy = spy ( ) ;
10821083 const { getByRole } = render (
10831084 < ButtonBase onClick = { onClickSpy } component = "div" >
@@ -1086,11 +1087,12 @@ describe('<ButtonBase />', () => {
10861087 ) ;
10871088 const button = getByRole ( 'button' ) ;
10881089
1089- act ( ( ) => {
1090+ await act ( async ( ) => {
10901091 button . focus ( ) ;
1091- fireEvent . keyDown ( button , {
1092- key : 'Enter' ,
1093- } ) ;
1092+ } ) ;
1093+
1094+ fireEvent . keyDown ( button , {
1095+ key : 'Enter' ,
10941096 } ) ;
10951097
10961098 expect ( onClickSpy . calledOnce ) . to . equal ( true ) ;
@@ -1131,7 +1133,7 @@ describe('<ButtonBase />', () => {
11311133 expect ( onClickSpy . callCount ) . to . equal ( 0 ) ;
11321134 } ) ;
11331135
1134- it ( 'prevents default with an anchor and empty href' , ( ) => {
1136+ it ( 'prevents default with an anchor and empty href' , async ( ) => {
11351137 const onClickSpy = spy ( ) ;
11361138 const { getByRole } = render (
11371139 < ButtonBase component = "a" onClick = { onClickSpy } >
@@ -1140,16 +1142,17 @@ describe('<ButtonBase />', () => {
11401142 ) ;
11411143 const button = getByRole ( 'button' ) ;
11421144
1143- act ( ( ) => {
1145+ await act ( async ( ) => {
11441146 button . focus ( ) ;
1145- fireEvent . keyDown ( button , { key : 'Enter' } ) ;
11461147 } ) ;
11471148
1149+ fireEvent . keyDown ( button , { key : 'Enter' } ) ;
1150+
11481151 expect ( onClickSpy . calledOnce ) . to . equal ( true ) ;
11491152 expect ( onClickSpy . firstCall . args [ 0 ] ) . to . have . property ( 'defaultPrevented' , true ) ;
11501153 } ) ;
11511154
1152- it ( 'should ignore anchors with href' , ( ) => {
1155+ it ( 'should ignore anchors with href' , async ( ) => {
11531156 const onClick = spy ( ) ;
11541157 const onKeyDown = spy ( ) ;
11551158 const { getByText } = render (
@@ -1159,11 +1162,12 @@ describe('<ButtonBase />', () => {
11591162 ) ;
11601163 const button = getByText ( 'Hello' ) ;
11611164
1162- act ( ( ) => {
1165+ await act ( async ( ) => {
11631166 button . focus ( ) ;
1164- fireEvent . keyDown ( button , {
1165- key : 'Enter' ,
1166- } ) ;
1167+ } ) ;
1168+
1169+ fireEvent . keyDown ( button , {
1170+ key : 'Enter' ,
11671171 } ) ;
11681172
11691173 expect ( onClick . callCount ) . to . equal ( 0 ) ;
0 commit comments