Skip to content

Commit

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

Co-Authored-By: Timothy Yung <[email protected]>
  • Loading branch information
acdlite and yungsters committed Jul 9, 2021
1 parent f85f429 commit df9a6ce
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 df9a6ce

Please sign in to comment.