UNPKG

react-native-ui-lib

Version:

<p align="center"> <img src="https://user-images.githubusercontent.com/1780255/105469025-56759000-5ca0-11eb-993d-3568c1fd54f4.png" height="250px" style="display:block"/> </p> <p align="center">UI Toolset & Components Library for React Native</p> <p a

31 lines (29 loc) 836 B
import { fireEvent } from '@testing-library/react-native'; import _ from 'lodash'; const TextDriverFactory = async ({ wrapperComponent, testID }) => { const text = await wrapperComponent.queryByTestId(testID); return { exists: () => !!text, getRootElement: () => text, getTextContent: () => { if (text) { return text.props.children; } else { console.warn(`Text component with testId:${testID}, is not found. So you can't get the content`); return null; } }, isClickable: () => typeof _.get(text, 'props.onPress') === 'function', click: () => { if (text) { fireEvent.press(text); } else { console.warn(`TextDriverFactory: cannot click because testID:${testID} were not found`); } } }; }; export default TextDriverFactory;