@@ -2211,151 +2211,6 @@ describe('ReactDOMFizzServer', () => {
22112211 expect ( getVisibleChildren ( container ) ) . toEqual ( < div > Hello</ div > ) ;
22122212 } ) ;
22132213
2214- // @gate enableSuspenseAvoidThisFallbackFizz
2215- it ( 'should respect unstable_avoidThisFallback' , async ( ) => {
2216- const resolved = {
2217- 0 : false ,
2218- 1 : false ,
2219- } ;
2220- const promiseRes = { } ;
2221- const promises = {
2222- 0 : new Promise ( res => {
2223- promiseRes [ 0 ] = ( ) => {
2224- resolved [ 0 ] = true ;
2225- res ( ) ;
2226- } ;
2227- } ) ,
2228- 1 : new Promise ( res => {
2229- promiseRes [ 1 ] = ( ) => {
2230- resolved [ 1 ] = true ;
2231- res ( ) ;
2232- } ;
2233- } ) ,
2234- } ;
2235-
2236- const InnerComponent = ( { isClient, depth} ) => {
2237- if ( isClient ) {
2238- // Resuspend after re-rendering on client to check that fallback shows on client
2239- throw new Promise ( ( ) => { } ) ;
2240- }
2241- if ( ! resolved [ depth ] ) {
2242- throw promises [ depth ] ;
2243- }
2244- return (
2245- < div >
2246- < Text text = { `resolved ${ depth } ` } />
2247- </ div >
2248- ) ;
2249- } ;
2250-
2251- function App ( { isClient} ) {
2252- return (
2253- < div >
2254- < Text text = "Non Suspense Content" />
2255- < Suspense
2256- fallback = {
2257- < span >
2258- < Text text = "Avoided Fallback" />
2259- </ span >
2260- }
2261- unstable_avoidThisFallback = { true } >
2262- < InnerComponent isClient = { isClient } depth = { 0 } />
2263- < div >
2264- < Suspense fallback = { < Text text = "Fallback" /> } >
2265- < Suspense
2266- fallback = {
2267- < span >
2268- < Text text = "Avoided Fallback2" />
2269- </ span >
2270- }
2271- unstable_avoidThisFallback = { true } >
2272- < InnerComponent isClient = { isClient } depth = { 1 } />
2273- </ Suspense >
2274- </ Suspense >
2275- </ div >
2276- </ Suspense >
2277- </ div >
2278- ) ;
2279- }
2280-
2281- await jest . runAllTimers ( ) ;
2282-
2283- await act ( ( ) => {
2284- const { pipe} = renderToPipeableStream ( < App isClient = { false } /> ) ;
2285- pipe ( writable ) ;
2286- } ) ;
2287-
2288- // Nothing is output since root has a suspense with avoidedThisFallback that hasn't resolved
2289- expect ( getVisibleChildren ( container ) ) . toEqual ( undefined ) ;
2290- expect ( container . innerHTML ) . not . toContain ( 'Avoided Fallback' ) ;
2291-
2292- // resolve first suspense component with avoidThisFallback
2293- await act ( ( ) => {
2294- promiseRes [ 0 ] ( ) ;
2295- } ) ;
2296-
2297- expect ( getVisibleChildren ( container ) ) . toEqual (
2298- < div >
2299- Non Suspense Content
2300- < div > resolved 0</ div >
2301- < div > Fallback</ div >
2302- </ div > ,
2303- ) ;
2304-
2305- expect ( container . innerHTML ) . not . toContain ( 'Avoided Fallback2' ) ;
2306-
2307- await act ( ( ) => {
2308- promiseRes [ 1 ] ( ) ;
2309- } ) ;
2310-
2311- expect ( getVisibleChildren ( container ) ) . toEqual (
2312- < div >
2313- Non Suspense Content
2314- < div > resolved 0</ div >
2315- < div >
2316- < div > resolved 1</ div >
2317- </ div >
2318- </ div > ,
2319- ) ;
2320-
2321- let root ;
2322- await act ( async ( ) => {
2323- root = ReactDOMClient . hydrateRoot ( container , < App isClient = { false } /> ) ;
2324- await waitForAll ( [ ] ) ;
2325- await jest . runAllTimers ( ) ;
2326- } ) ;
2327-
2328- // No change after hydration
2329- expect ( getVisibleChildren ( container ) ) . toEqual (
2330- < div >
2331- Non Suspense Content
2332- < div > resolved 0</ div >
2333- < div >
2334- < div > resolved 1</ div >
2335- </ div >
2336- </ div > ,
2337- ) ;
2338-
2339- await act ( async ( ) => {
2340- // Trigger update by changing isClient to true
2341- root . render ( < App isClient = { true } /> ) ;
2342- await waitForAll ( [ ] ) ;
2343- await jest . runAllTimers ( ) ;
2344- } ) ;
2345-
2346- // Now that we've resuspended at the root we show the root fallback
2347- expect ( getVisibleChildren ( container ) ) . toEqual (
2348- < div >
2349- Non Suspense Content
2350- < div style = "display: none;" > resolved 0</ div >
2351- < div style = "display: none;" >
2352- < div > resolved 1</ div >
2353- </ div >
2354- < span > Avoided Fallback</ span >
2355- </ div > ,
2356- ) ;
2357- } ) ;
2358-
23592214 it ( 'calls getServerSnapshot instead of getSnapshot' , async ( ) => {
23602215 const ref = React . createRef ( ) ;
23612216
0 commit comments