File tree 1 file changed +32
-0
lines changed
packages/react-native-renderer/src/__tests__
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1064,4 +1064,36 @@ describe('ReactFabric', () => {
1064
1064
expect ( TextInputState . focusTextInput ) . toHaveBeenCalledTimes ( 1 ) ;
1065
1065
expect ( TextInputState . focusTextInput ) . toHaveBeenCalledWith ( viewRef . current ) ;
1066
1066
} ) ;
1067
+
1068
+ it ( 'should no-op if calling sendAccessibilityEvent on unmounted refs' , ( ) => {
1069
+ const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
1070
+ validAttributes : { foo : true } ,
1071
+ uiViewClassName : 'RCTView' ,
1072
+ } ) ) ;
1073
+
1074
+ nativeFabricUIManager . sendAccessibilityEvent . mockReset ( ) ;
1075
+
1076
+ let viewRef ;
1077
+ act ( ( ) => {
1078
+ ReactFabric . render (
1079
+ < View
1080
+ ref = { ref => {
1081
+ viewRef = ref ;
1082
+ } }
1083
+ /> ,
1084
+ 11 ,
1085
+ ) ;
1086
+ } ) ;
1087
+ const dangerouslyRetainedViewRef = viewRef ;
1088
+ act ( ( ) => {
1089
+ ReactFabric . stopSurface ( 11 ) ;
1090
+ } ) ;
1091
+
1092
+ ReactFabric . sendAccessibilityEvent (
1093
+ dangerouslyRetainedViewRef ,
1094
+ 'eventTypeName' ,
1095
+ ) ;
1096
+
1097
+ expect ( nativeFabricUIManager . sendAccessibilityEvent ) . not . toBeCalled ( ) ;
1098
+ } ) ;
1067
1099
} ) ;
You can’t perform that action at this time.
0 commit comments