1
1
import * as React from 'react' ;
2
2
import { View , Text , TextInput } from 'react-native' ;
3
3
import { render } from '..' ;
4
- import { getHostSelf } from '../helpers/component-tree' ;
5
4
6
5
/**
7
6
* Tests in this file are intended to give us an proactive warning that React Native behavior has
@@ -10,8 +9,6 @@ import { getHostSelf } from '../helpers/component-tree';
10
9
11
10
test ( 'React Native API assumption: <View> renders single host element' , ( ) => {
12
11
const view = render ( < View testID = "test" /> ) ;
13
- const hostView = view . getByTestId ( 'test' ) ;
14
- expect ( getHostSelf ( hostView ) ) . toBe ( hostView ) ;
15
12
16
13
expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
17
14
<View
@@ -22,9 +19,7 @@ test('React Native API assumption: <View> renders single host element', () => {
22
19
23
20
test ( 'React Native API assumption: <Text> renders single host element' , ( ) => {
24
21
const view = render ( < Text testID = "test" > Hello</ Text > ) ;
25
- const compositeView = view . getByText ( 'Hello' ) ;
26
- const hostView = view . getByTestId ( 'test' ) ;
27
- expect ( getHostSelf ( compositeView ) ) . toBe ( hostView ) ;
22
+ expect ( view . getByText ( 'Hello' ) ) . toBe ( view . getByTestId ( 'test' ) ) ;
28
23
29
24
expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
30
25
<Text
@@ -45,11 +40,9 @@ test('React Native API assumption: nested <Text> renders single host element', (
45
40
</ Text >
46
41
</ Text >
47
42
) ;
48
- expect ( getHostSelf ( view . getByText ( / H e l l o / ) ) ) . toBe ( view . getByTestId ( 'test' ) ) ;
49
- expect ( getHostSelf ( view . getByText ( 'Before' ) ) ) . toBe (
50
- view . getByTestId ( 'before' )
51
- ) ;
52
- expect ( getHostSelf ( view . getByText ( 'Deeply nested' ) ) ) . toBe (
43
+ expect ( view . getByText ( / H e l l o / ) ) . toBe ( view . getByTestId ( 'test' ) ) ;
44
+ expect ( view . getByText ( 'Before' ) ) . toBe ( view . getByTestId ( 'before' ) ) ;
45
+ expect ( view . getByText ( 'Deeply nested' ) ) . toBe (
53
46
view . getByTestId ( 'deeplyNested' )
54
47
) ;
55
48
@@ -85,9 +78,9 @@ test('React Native API assumption: <TextInput> renders single host element', ()
85
78
placeholder = "Placeholder"
86
79
/>
87
80
) ;
88
- const compositeView = view . getByPlaceholderText ( 'Placeholder' ) ;
89
- const hostView = view . getByTestId ( 'test' ) ;
90
- expect ( getHostSelf ( compositeView ) ) . toBe ( hostView ) ;
81
+ expect ( view . getByPlaceholderText ( 'Placeholder' ) ) . toBe (
82
+ view . getByTestId ( 'test' )
83
+ ) ;
91
84
92
85
expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
93
86
<TextInput
0 commit comments