@@ -4612,21 +4612,20 @@ function testDomRouter(
4612
4612
} ) ;
4613
4613
4614
4614
it ( "show all fetchers via useFetchers and cleans up fetchers on unmount" , async ( ) => {
4615
- let dfd1 = createDeferred ( ) ;
4616
- let dfd2 = createDeferred ( ) ;
4615
+ let navDfd = createDeferred ( ) ;
4616
+ let fetchDfd1 = createDeferred ( ) ;
4617
+ let fetchDfd2 = createDeferred ( ) ;
4617
4618
let router = createTestRouter (
4618
4619
createRoutesFromElements (
4619
4620
< Route path = "/" element = { < Parent /> } >
4620
- < Route
4621
- path = "/1"
4622
- loader = { async ( ) => await dfd1 . promise }
4623
- element = { < Comp1 /> }
4624
- />
4621
+ < Route path = "/1" element = { < Comp1 /> } />
4625
4622
< Route
4626
4623
path = "/2"
4627
- loader = { async ( ) => await dfd2 . promise }
4624
+ loader = { ( ) => navDfd . promise }
4628
4625
element = { < Comp2 /> }
4629
4626
/>
4627
+ < Route path = "/fetch-1" loader = { ( ) => fetchDfd1 . promise } />
4628
+ < Route path = "/fetch-2" loader = { ( ) => fetchDfd2 . promise } />
4630
4629
</ Route >
4631
4630
) ,
4632
4631
{
@@ -4658,7 +4657,7 @@ function testDomRouter(
4658
4657
1{ fetcher . state }
4659
4658
{ fetcher . data || "null" }
4660
4659
</ p >
4661
- < button onClick = { ( ) => fetcher . load ( "/1" ) } > load</ button >
4660
+ < button onClick = { ( ) => fetcher . load ( "/fetch- 1" ) } > load</ button >
4662
4661
</ >
4663
4662
) ;
4664
4663
}
@@ -4671,7 +4670,7 @@ function testDomRouter(
4671
4670
2{ fetcher . state }
4672
4671
{ fetcher . data || "null" }
4673
4672
</ p >
4674
- < button onClick = { ( ) => fetcher . load ( "/2" ) } > load</ button >
4673
+ < button onClick = { ( ) => fetcher . load ( "/fetch- 2" ) } > load</ button >
4675
4674
</ >
4676
4675
) ;
4677
4676
}
@@ -4718,7 +4717,7 @@ function testDomRouter(
4718
4717
` ) ;
4719
4718
4720
4719
// Resolve Comp1 fetcher - UI updates
4721
- dfd1 . resolve ( "data 1" ) ;
4720
+ fetchDfd1 . resolve ( "data 1" ) ;
4722
4721
await waitFor ( ( ) => screen . getByText ( / d a t a 1 / ) ) ;
4723
4722
expect ( getHtml ( container . querySelector ( "#output" ) ! ) )
4724
4723
. toMatchInlineSnapshot ( `
@@ -4761,7 +4760,7 @@ function testDomRouter(
4761
4760
` ) ;
4762
4761
4763
4762
// Resolve Comp2 loader and complete navigation
4764
- dfd2 . resolve ( "data 2 " ) ;
4763
+ navDfd . resolve ( "nav data " ) ;
4765
4764
await waitFor ( ( ) => screen . getByText ( / 2 .* i d l e / ) ) ;
4766
4765
expect ( getHtml ( container . querySelector ( "#output" ) ! ) )
4767
4766
. toMatchInlineSnapshot ( `
@@ -4782,8 +4781,7 @@ function testDomRouter(
4782
4781
</div>"
4783
4782
` ) ;
4784
4783
4785
- // Activate Comp2 fetcher, which now officially kicks out Comp1's
4786
- // fetcher from useFetchers and reflects Comp2's fetcher
4784
+ // Activate Comp2 fetcher
4787
4785
fireEvent . click ( screen . getByText ( "load" ) ) ;
4788
4786
expect ( getHtml ( container . querySelector ( "#output" ) ! ) )
4789
4787
. toMatchInlineSnapshot ( `
@@ -4805,7 +4803,8 @@ function testDomRouter(
4805
4803
` ) ;
4806
4804
4807
4805
// Comp2 loader resolves with the same data, useFetchers reflects idle-done
4808
- await waitFor ( ( ) => screen . getByText ( / 2 .* i d l e / ) ) ;
4806
+ fetchDfd2 . resolve ( "data 2" ) ;
4807
+ await waitFor ( ( ) => screen . getByText ( / d a t a 2 / ) ) ;
4809
4808
expect ( getHtml ( container . querySelector ( "#output" ) ! ) )
4810
4809
. toMatchInlineSnapshot ( `
4811
4810
"<div
0 commit comments