11import * as React from 'react' ;
22import { View , Text , TextInput } from 'react-native' ;
33import { render } from '..' ;
4- import { getHostSelf } from '../helpers/component-tree' ;
54
65/**
76 * 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';
109
1110test ( 'React Native API assumption: <View> renders single host element' , ( ) => {
1211 const view = render ( < View testID = "test" /> ) ;
13- const hostView = view . getByTestId ( 'test' ) ;
14- expect ( getHostSelf ( hostView ) ) . toBe ( hostView ) ;
1512
1613 expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
1714 <View
@@ -22,9 +19,7 @@ test('React Native API assumption: <View> renders single host element', () => {
2219
2320test ( 'React Native API assumption: <Text> renders single host element' , ( ) => {
2421 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' ) ) ;
2823
2924 expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
3025 <Text
@@ -45,11 +40,9 @@ test('React Native API assumption: nested <Text> renders single host element', (
4540 </ Text >
4641 </ Text >
4742 ) ;
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 (
5346 view . getByTestId ( 'deeplyNested' )
5447 ) ;
5548
@@ -85,9 +78,9 @@ test('React Native API assumption: <TextInput> renders single host element', ()
8578 placeholder = "Placeholder"
8679 />
8780 ) ;
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+ ) ;
9184
9285 expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
9386 <TextInput
0 commit comments