Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Taken from facebook#21837 (comment)

Co-Authored-By: Timothy Yung <yungsters@fb.com>

Co-authored-by: Timothy Yung <yungsters@fb.com>
  • Loading branch information
2 people authored and zhengjitf committed Apr 15, 2022
1 parent cff7073 commit 364efa8
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1064,4 +1064,36 @@ describe('ReactFabric', () => {
expect(TextInputState.focusTextInput).toHaveBeenCalledTimes(1);
expect(TextInputState.focusTextInput).toHaveBeenCalledWith(viewRef.current);
});

it('should no-op if calling sendAccessibilityEvent on unmounted refs', () => {
const View = createReactNativeComponentClass('RCTView', () => ({
validAttributes: {foo: true},
uiViewClassName: 'RCTView',
}));

nativeFabricUIManager.sendAccessibilityEvent.mockReset();

let viewRef;
act(() => {
ReactFabric.render(
<View
ref={ref => {
viewRef = ref;
}}
/>,
11,
);
});
const dangerouslyRetainedViewRef = viewRef;
act(() => {
ReactFabric.stopSurface(11);
});

ReactFabric.sendAccessibilityEvent(
dangerouslyRetainedViewRef,
'eventTypeName',
);

expect(nativeFabricUIManager.sendAccessibilityEvent).not.toBeCalled();
});
});

0 comments on commit 364efa8

Please sign in to comment.