diff --git a/src/__tests__/byTestId.test.js b/src/__tests__/byTestId.test.js new file mode 100644 index 000000000..ab195dbf7 --- /dev/null +++ b/src/__tests__/byTestId.test.js @@ -0,0 +1,173 @@ +// @flow +import React from 'react'; +import { View, Text, TextInput, TouchableOpacity, Button } from 'react-native'; +import { render } from '..'; + +const PLACEHOLDER_FRESHNESS = 'Add custom freshness'; +const PLACEHOLDER_CHEF = 'Who inspected freshness?'; +const INPUT_FRESHNESS = 'Custom Freshie'; +const INPUT_CHEF = 'I inspected freshie'; + +class MyButton extends React.Component { + render() { + return ( + + {this.props.children} + + ); + } +} + +class Banana extends React.Component { + state = { + fresh: false, + }; + + componentDidUpdate() { + if (this.props.onUpdate) { + this.props.onUpdate(); + } + } + + componentWillUnmount() { + if (this.props.onUnmount) { + this.props.onUnmount(); + } + } + + changeFresh = () => { + this.setState((state) => ({ + fresh: !state.fresh, + })); + }; + + render() { + const test = 0; + return ( + + Is the banana fresh? + + {this.state.fresh ? 'fresh' : 'not fresh'} + + + + + Change freshness! + + First Text + Second Text + {test} + + ); + } +} + +const MyComponent = () => { + return My Component; +}; + +test('getByTestId returns only native elements', () => { + const { getByTestId, getAllByTestId } = render( + + Text + + +