@samitouri / QOS-React-2 / commits / cb8afda183

Add test for #21837 (#21842)

Taken from https://github.com/facebook/react/pull/21837#issuecomment-876788973 Co-Authored-By: Timothy Yung <yungsters@fb.com> Co-authored-by: Timothy Yung <yungsters@fb.com>

Andrew Clark committed Jul 8, 2021 at 23:01 UTC cb8afda183e9c931978279d3a1706d1d9c905484
1 file changed +32
packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js
+32
@@ -1064,4 +1064,36 @@ describe('ReactFabric', () => {
1064 expect(TextInputState.focusTextInput).toHaveBeenCalledTimes(1);
1065 expect(TextInputState.focusTextInput).toHaveBeenCalledWith(viewRef.current);
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 + });
1099 });