@@ -41,10 +41,10 @@ describe('ReactSuspense', () => {
4141 textResourceShouldFail = false ;
4242 } ) ;
4343
44- // function div(...children) {
45- // children = children.map(c => (typeof c === 'string' ? {text: c} : c));
46- // return {type: 'div', children, prop: undefined};
47- // }
44+ function div ( ...children ) {
45+ children = children . map ( c => ( typeof c === 'string' ? { text : c } : c ) ) ;
46+ return { type : 'div' , children, prop : undefined } ;
47+ }
4848
4949 function span ( prop ) {
5050 return { type : 'span' , children : [ ] , prop} ;
@@ -756,6 +756,42 @@ describe('ReactSuspense', () => {
756756 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'C' ) ] ) ;
757757 } ) ;
758758
759+ it ( 'can hide a tree to unblock its surroundings' , async ( ) => {
760+ function App ( ) {
761+ return (
762+ < Timeout ms = { 1000 } >
763+ { didTimeout => (
764+ < Fragment >
765+ < div hidden = { didTimeout } >
766+ < AsyncText text = "Async" ms = { 2000 } />
767+ </ div >
768+ { didTimeout ? < Text text = "Loading..." /> : null }
769+ </ Fragment >
770+ ) }
771+ </ Timeout >
772+ ) ;
773+ }
774+
775+ ReactNoop . render ( < App /> ) ;
776+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [Async]' ] ) ;
777+ expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
778+
779+ ReactNoop . expire ( 1000 ) ;
780+ await advanceTimers ( 1000 ) ;
781+ expect ( ReactNoop . flush ( ) ) . toEqual ( [
782+ 'Suspend! [Async]' ,
783+ 'Loading...' ,
784+ 'Suspend! [Async]' ,
785+ ] ) ;
786+ expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ div ( ) , span ( 'Loading...' ) ] ) ;
787+
788+ ReactNoop . expire ( 1000 ) ;
789+ await advanceTimers ( 1000 ) ;
790+
791+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Promise resolved [Async]' , 'Async' ] ) ;
792+ expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ div ( span ( 'Async' ) ) ] ) ;
793+ } ) ;
794+
759795 describe ( 'splitting a high-pri update into high and low' , ( ) => {
760796 React = require ( 'react' ) ;
761797
0 commit comments