Тестирование eventListener в componentDidMount - PullRequest
0 голосов
/ 13 марта 2019

У меня есть компонент react-native, который прослушивает событие Linking url. Как бы я запустил это событие с react-native-testing-library?

Пример:

import React, { PureComponent } from 'react';
import { View, Text, Linking, ActivityIndicator } from 'react-native';
import SafariView from 'react-native-safari-view';

class WebAuthView extends Component<Props, State> {
  componentDidMount() {
        Linking.addEventListener('url', this.handleAuthUrl);
        SafariView.addEventListener('onDismiss', this.handleDismiss);
   }

   componentWillUnmount() {
       Linking.removeEventListener('url', this.handleAuthUrl);
       SafariView.removeEventListener('onDismiss', this.handleDismiss);
   }

   handleAuthUrl = ({url}) => {
     // Implementation goes here
   }

   render() {
     // ....
   }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...