1401
);
1402
});
1403
1404
+ // @gate enableLegacyCache
1405
+ it('should wait to reveal an inner child when inner one reveals first', async () => {
1406
+ function App({outerChildren, innerChildren}) {
1407
+ return (
1408
+ <Suspense fallback={<Text text="OuterFallback" />} name="Outer">
1409
+ <Suspense fallback={<Text text="InnerFallback" />} name="Inner">
1410
+ <div>{innerChildren}</div>
1411
+ </Suspense>
1412
+ {outerChildren}
1413
+ </Suspense>
1414
+ );
1415
+ }
1416
+
1417
+ // Mount
1418
+ await act(() => {
1419
+ ReactNoop.render(<App />);
1420
+ });
1421
+ assertLog([]);
1422
+ expect(ReactNoop).toMatchRenderedOutput(<div />);
1423
+
1424
+ // Resuspend inner boundary
1425
+ await act(() => {
1426
+ ReactNoop.render(
1427
+ <App
1428
+ outerChildren={null}
1429
+ innerChildren={<AsyncText text="InnerAsync" />}
1430
+ />,
1431
+ );
1432
+ });
1433
+ assertLog([
1434
+ 'Suspend:InnerAsync',
1435
+ 'Text:InnerFallback render',
1436
+ 'Text:InnerFallback create insertion',
1437
+ 'Text:InnerFallback create layout',
1438
+ 'Text:InnerFallback create passive',
1439
+ 'Suspend:InnerAsync',
1440
+ ]);
1441
+ expect(ReactNoop).toMatchRenderedOutput(
1442
+ <>
1443
+ <div hidden={true} />
1444
+ <span prop="InnerFallback" />
1445
+ </>,
1446
+ );
1447
+
1448
+ // Resuspend both boundaries
1449
+ await act(() => {
1450
+ ReactNoop.render(
1451
+ <App
1452
+ outerChildren={<AsyncText text="OuterAsync" />}
1453
+ innerChildren={<AsyncText text="InnerAsync" />}
1454
+ />,
1455
+ );
1456
+ });
1457
+ assertLog([
1458
+ 'Suspend:InnerAsync',
1459
+ 'Text:InnerFallback render',
1460
+ 'Suspend:OuterAsync',
1461
+ 'Text:OuterFallback render',
1462
+ 'Text:InnerFallback destroy layout',
1463
+ 'Text:OuterFallback create insertion',
1464
+ 'Text:OuterFallback create layout',
1465
+ 'Text:OuterFallback create passive',
1466
+ 'Suspend:InnerAsync',
1467
+ 'Text:InnerFallback render',
1468
+ 'Suspend:OuterAsync',
1469
+ ]);
1470
+ expect(ReactNoop).toMatchRenderedOutput(
1471
+ <>
1472
+ <div hidden={true} />
1473
+ <span prop="InnerFallback" hidden={true} />
1474
+ <span prop="OuterFallback" />
1475
+ </>,
1476
+ );
1477
+
1478
+ // Unsuspend the inner Suspense subtree only
1479
+ // Interestingly, this never commits because the tree is left suspended.
1480
+ // If it did commit, it would potentially cause the div to incorrectly reappear.
1481
+ await act(() => {
1482
+ ReactNoop.render(
1483
+ <App
1484
+ outerChildren={<AsyncText text="OuterAsync" />}
1485
+ innerChildren={null}
1486
+ />,
1487
+ );
1488
+ });
1489
+ assertLog([
1490
+ 'Suspend:OuterAsync',
1491
+ 'Text:OuterFallback render',
1492
+ 'Suspend:OuterAsync',
1493
+ ]);
1494
+ expect(ReactNoop).toMatchRenderedOutput(
1495
+ <>
1496
+ <div hidden={true} />
1497
+ <span prop="InnerFallback" hidden={true} />
1498
+ <span prop="OuterFallback" />
1499
+ </>,
1500
+ );
1501
+ });
1502
+
1503
// @gate enableLegacyCache
1504
it('should show nested host nodes if multiple boundaries resolve at the same time', async () => {
1505
function App({innerChildren = null, outerChildren = null}) {