'How to write test cases for the function that will be called in one screen when coming from other screen react native

I'm writing the test cases react native. Here in code I have a functionality I need to update data in previous screen while going back from the current screen. For that the code is as follows:

while navigating from the screen I'm writing as

  this.props.navigation.navigate('screen1', {
  updateData: this.updateData,
});

now while coming to this screen back I need to update this screen by passing the data in update data function using

 this.props.navigation.state.params.updateData(true, callBackData);
 this.props.navigation.goBack();

callBackData is the data I will be passing back to screen 1.

Functionlity wise everything is working. But I'm not sure how to test case for this scenario to cover the update function in the screen 1. Help me out with the suggestions.

Note: I tried looking into possible solutions over the Stackoverflow community but couldn't find one.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source