@@ -37,6 +37,7 @@ describe('ReactTestRendererTraversal', () => {
3737 < View void = "void" />
3838 < View void = "void" />
3939 </ ExampleNull >
40+ < ExampleForwardRef qux = "qux" />
4041 </ View >
4142 </ View >
4243 ) ;
@@ -48,13 +49,17 @@ describe('ReactTestRendererTraversal', () => {
4849 const ExampleFn = props => < View baz = "baz" /> ;
4950 const ExampleNull = props => null ;
5051
52+ const ExampleForwardRef = React . forwardRef ( ( props , ref ) => (
53+ < View { ...props } ref = { ref } />
54+ ) ) ;
55+
5156 it ( 'initializes' , ( ) => {
5257 const render = ReactTestRenderer . create ( < Example /> ) ;
5358 const hasFooProp = node => node . props . hasOwnProperty ( 'foo' ) ;
5459
5560 // assert .props, .type and .parent attributes
5661 const foo = render . root . find ( hasFooProp ) ;
57- expect ( foo . props . children ) . toHaveLength ( 7 ) ;
62+ expect ( foo . props . children ) . toHaveLength ( 8 ) ;
5863 expect ( foo . type ) . toBe ( View ) ;
5964 expect ( render . root . parent ) . toBe ( null ) ;
6065 expect ( foo . children [ 0 ] . parent ) . toBe ( foo ) ;
@@ -116,14 +121,16 @@ describe('ReactTestRendererTraversal', () => {
116121
117122 expect ( ( ) => render . root . findByType ( ExampleFn ) ) . not . toThrow ( ) ; // 1 match
118123 expect ( ( ) => render . root . findByType ( View ) ) . not . toThrow ( ) ; // 1 match
124+ expect ( ( ) => render . root . findByType ( ExampleForwardRef ) ) . not . toThrow ( ) ; // 1 match
119125 // note: there are clearly multiple <View /> in general, but there
120126 // is only one being rendered at root node level
121127 expect ( ( ) => render . root . findByType ( ExampleNull ) ) . toThrow ( ) ; // 2 matches
122128
123129 expect ( render . root . findAllByType ( ExampleFn ) ) . toHaveLength ( 1 ) ;
124130 expect ( render . root . findAllByType ( View , { deep : false } ) ) . toHaveLength ( 1 ) ;
125- expect ( render . root . findAllByType ( View ) ) . toHaveLength ( 7 ) ;
131+ expect ( render . root . findAllByType ( View ) ) . toHaveLength ( 8 ) ;
126132 expect ( render . root . findAllByType ( ExampleNull ) ) . toHaveLength ( 2 ) ;
133+ expect ( render . root . findAllByType ( ExampleForwardRef ) ) . toHaveLength ( 1 ) ;
127134
128135 const nulls = render . root . findAllByType ( ExampleNull ) ;
129136 expect ( nulls [ 0 ] . findAllByType ( View ) ) . toHaveLength ( 0 ) ;
@@ -138,17 +145,21 @@ describe('ReactTestRendererTraversal', () => {
138145 const foo = 'foo' ;
139146 const bar = 'bar' ;
140147 const baz = 'baz' ;
148+ const qux = 'qux' ;
141149
142150 expect ( ( ) => render . root . findByProps ( { foo} ) ) . not . toThrow ( ) ; // 1 match
143151 expect ( ( ) => render . root . findByProps ( { bar} ) ) . toThrow ( ) ; // >1 matches
144152 expect ( ( ) => render . root . findByProps ( { baz} ) ) . toThrow ( ) ; // >1 matches
153+ expect ( ( ) => render . root . findByProps ( { qux} ) ) . not . toThrow ( ) ; // 1 match
145154
146155 expect ( render . root . findAllByProps ( { foo} , { deep : false } ) ) . toHaveLength ( 1 ) ;
147156 expect ( render . root . findAllByProps ( { bar} , { deep : false } ) ) . toHaveLength ( 5 ) ;
148157 expect ( render . root . findAllByProps ( { baz} , { deep : false } ) ) . toHaveLength ( 2 ) ;
158+ expect ( render . root . findAllByProps ( { qux} , { deep : false } ) ) . toHaveLength ( 1 ) ;
149159
150160 expect ( render . root . findAllByProps ( { foo} ) ) . toHaveLength ( 2 ) ;
151161 expect ( render . root . findAllByProps ( { bar} ) ) . toHaveLength ( 9 ) ;
152162 expect ( render . root . findAllByProps ( { baz} ) ) . toHaveLength ( 4 ) ;
163+ expect ( render . root . findAllByProps ( { qux} ) ) . toHaveLength ( 3 ) ;
153164 } ) ;
154165} ) ;
0 commit comments