title: How to test actionsheet for react native in jest?
body: <p>I am using <code>ActionSheetProvider</code> from <a href="https://github.com/expo/react-native-action-sheet" rel="nofollow noreferrer">https://github.com/expo/react-native-action-sheet</a> for my react native project.</p>
  
  <p>This is how I use it in my code:</p>
  
  <pre><code>import { connectActionSheet } from '@expo/react-native-action-sheet';
  
  export default
  @connectActionSheet
  class MyComponent extends React.Component {
  
  ...
  
  &lt;MyCustomIcon onPress={() =&gt; this.showMenu(item)}/&gt;
  
  ...
  
  showMenu = targetItem =&gt; {
  
    this.props.showActionSheetWithOptions(
    {
      options: ['cancel','rename','hide','delete'],
      cancelButtonIndex: 0,
      destructiveButtonIndex: 3,
    },
    index =&gt; {
       if (index === 3) { //delete item }
      }
     }
    );
  };
  </code></pre>
  
  <p>This is what I've done so far, but I don't know how to trigger index === 3 in my test:</p>
  
  <pre><code>const showActionSheetWithOptions = jest.fn();
  
  const renderComponent = overrides =&gt; {
  props = {
    showActionSheetWithOptions,
    ...overrides,
  };
  
  return shallow(&lt;MyComponent.wrappedComponent {...props} /&gt;);
  };
  
  
    it('should check if delete option is selected', () =&gt; {
    const wrapper = renderComponent();
    const instance = wrapper.instance();
    const myIcon = wrapper.find({ testID: 'my-icon' });
  
    const spyShowMenu = jest.spyOn(instance, 'showMenu');
    myIcon.props.onPress();
    expect(spyShowMenu).toHaveBeenCalled(); // this test passes
    // Now that the action sheet has been displayed, how to select delete option?
    });
  });
  </code></pre>