|
1 | 1 | import * as React from 'react'; |
2 | 2 | import { TextInput, View } from 'react-native'; |
3 | | - |
4 | | -import { render, screen } from '../..'; |
| 3 | +import { fireEvent, render, screen } from '../..'; |
| 4 | +import '../../matchers/extend-expect'; |
5 | 5 |
|
6 | 6 | const PLACEHOLDER_FRESHNESS = 'Add custom freshness'; |
7 | 7 | const PLACEHOLDER_CHEF = 'Who inspected freshness?'; |
@@ -30,13 +30,12 @@ const Banana = () => ( |
30 | 30 |
|
31 | 31 | test('getByDisplayValue, queryByDisplayValue', () => { |
32 | 32 | render(<Banana />); |
33 | | - const input = screen.getByDisplayValue(/custom/i); |
34 | 33 |
|
35 | | - expect(input.props.value).toBe(INPUT_FRESHNESS); |
| 34 | + const input = screen.getByDisplayValue(/custom/i); |
| 35 | + expect(input).toHaveDisplayValue(INPUT_FRESHNESS); |
36 | 36 |
|
37 | 37 | const sameInput = screen.getByDisplayValue(INPUT_FRESHNESS); |
38 | | - |
39 | | - expect(sameInput.props.value).toBe(INPUT_FRESHNESS); |
| 38 | + expect(sameInput).toHaveDisplayValue(INPUT_FRESHNESS); |
40 | 39 | expect(() => screen.getByDisplayValue('no value')).toThrow( |
41 | 40 | 'Unable to find an element with displayValue: no value', |
42 | 41 | ); |
@@ -203,3 +202,13 @@ test('error message renders the element tree, preserving only helpful props', as |
203 | 202 | />" |
204 | 203 | `); |
205 | 204 | }); |
| 205 | + |
| 206 | +test('supports unmanaged TextInput element', () => { |
| 207 | + render(<TextInput testID="input" />); |
| 208 | + |
| 209 | + const input = screen.getByDisplayValue(''); |
| 210 | + expect(input).toHaveDisplayValue(''); |
| 211 | + |
| 212 | + fireEvent.changeText(input, 'Hello!'); |
| 213 | + expect(input).toHaveDisplayValue('Hello!'); |
| 214 | +}); |
0 commit comments