@@ -1462,6 +1462,51 @@ it('throws when Screen is not the direct children', () => {
1462
1462
) ;
1463
1463
} ) ;
1464
1464
1465
+ it ( 'throws when undefined component is a direct children' , ( ) => {
1466
+ const TestNavigator = ( props : any ) => {
1467
+ useNavigationBuilder ( MockRouter , props ) ;
1468
+ return null ;
1469
+ } ;
1470
+
1471
+ const Undefined = undefined ;
1472
+
1473
+ const spy = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
1474
+ const element = (
1475
+ < BaseNavigationContainer >
1476
+ < TestNavigator >
1477
+ { /* @ts -ignore */ }
1478
+ < Undefined name = "foo" component = { jest . fn ( ) } />
1479
+ </ TestNavigator >
1480
+ </ BaseNavigationContainer >
1481
+ ) ;
1482
+
1483
+ spy . mockRestore ( ) ;
1484
+
1485
+ expect ( ( ) => render ( element ) . update ( element ) ) . toThrowError (
1486
+ "A navigator can only contain 'Screen' components as its direct children (found 'undefined' for the screen 'foo')"
1487
+ ) ;
1488
+ } ) ;
1489
+
1490
+ it ( 'throws when a tag is a direct children' , ( ) => {
1491
+ const TestNavigator = ( props : any ) => {
1492
+ useNavigationBuilder ( MockRouter , props ) ;
1493
+ return null ;
1494
+ } ;
1495
+
1496
+ const element = (
1497
+ < BaseNavigationContainer >
1498
+ < TestNavigator >
1499
+ { /* @ts -ignore */ }
1500
+ < screen name = "foo" component = { jest . fn ( ) } />
1501
+ </ TestNavigator >
1502
+ </ BaseNavigationContainer >
1503
+ ) ;
1504
+
1505
+ expect ( ( ) => render ( element ) . update ( element ) ) . toThrowError (
1506
+ "A navigator can only contain 'Screen' components as its direct children (found 'screen' for the screen 'foo')"
1507
+ ) ;
1508
+ } ) ;
1509
+
1465
1510
it ( 'throws when a React Element is not the direct children' , ( ) => {
1466
1511
const TestNavigator = ( props : any ) => {
1467
1512
useNavigationBuilder ( MockRouter , props ) ;
0 commit comments