Skip to content

Commit

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

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

Co-authored-by: Timothy Yung <yungsters@fb.com>
  • Loading branch information
acdlite and yungsters authored Jul 9, 2021
1 parent f85f429 commit cb8afda
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 cb8afda

Please sign in to comment.