@@ -116,6 +116,50 @@ describe("fetchers", () => {
116
116
expect ( router . _internalFetchControllers . size ) . toBe ( 0 ) ;
117
117
} ) ;
118
118
119
+ it ( "unabstracted loader fetch with fog of war" , async ( ) => {
120
+ let dfd = createDeferred ( ) ;
121
+ let router = createRouter ( {
122
+ history : createMemoryHistory ( { initialEntries : [ "/" ] } ) ,
123
+ routes : [
124
+ {
125
+ id : "root" ,
126
+ // Note: No path is provided on the root route in this test to
127
+ // ensure nothing matches before routes are patched
128
+ } ,
129
+ ] ,
130
+ hydrationData : {
131
+ loaderData : { root : "ROOT DATA" } ,
132
+ } ,
133
+ async patchRoutesOnNavigation ( { path, patch } ) {
134
+ if ( path === "/lazy" ) {
135
+ patch ( "root" , [
136
+ {
137
+ id : "lazy" ,
138
+ path : "/lazy" ,
139
+ loader : ( ) => dfd . promise ,
140
+ } ,
141
+ ] ) ;
142
+ }
143
+ } ,
144
+ } ) ;
145
+ let fetcherData = getFetcherData ( router ) ;
146
+
147
+ let key = "key" ;
148
+ router . fetch ( key , "lazy" , "/lazy" ) ;
149
+ expect ( router . getFetcher ( key ) ) . toEqual ( {
150
+ state : "loading" ,
151
+ formMethod : undefined ,
152
+ formEncType : undefined ,
153
+ formData : undefined ,
154
+ } ) ;
155
+
156
+ await dfd . resolve ( "DATA" ) ;
157
+ expect ( router . getFetcher ( key ) ) . toBe ( IDLE_FETCHER ) ;
158
+ expect ( fetcherData . get ( key ) ) . toBe ( "DATA" ) ;
159
+
160
+ expect ( router . _internalFetchControllers . size ) . toBe ( 0 ) ;
161
+ } ) ;
162
+
119
163
it ( "loader fetch" , async ( ) => {
120
164
let t = initializeTest ( {
121
165
url : "/foo" ,
0 commit comments