@@ -356,6 +356,84 @@ test('it should preload entry point with both queries and nested entry points',
356
356
} ) ;
357
357
} ) ;
358
358
359
+ test ( 'it should dispose nested entry points' , ( ) => {
360
+ const env = createMockEnvironment ( ) ;
361
+ const nestedEntryPoint = {
362
+ getPreloadProps ( params ) {
363
+ return {
364
+ queries : {
365
+ myNestedQuery : {
366
+ parameters : {
367
+ kind : 'PreloadableConcreteRequest' ,
368
+ params : {
369
+ operationKind : 'query' ,
370
+ name : 'MyNestedQuery' ,
371
+ id : 'nested-query-id' ,
372
+ text : null ,
373
+ metadata : { } ,
374
+ } ,
375
+ } ,
376
+ variables : {
377
+ id : params . id ,
378
+ } ,
379
+ } ,
380
+ } ,
381
+ } ;
382
+ } ,
383
+ root : ( new FakeJSResource ( null ) : $FlowFixMe ) ,
384
+ } ;
385
+ const entryPoint = {
386
+ getPreloadProps ( params ) {
387
+ return {
388
+ queries : {
389
+ myTestQuery : {
390
+ parameters : {
391
+ kind : 'PreloadableConcreteRequest' ,
392
+ params : {
393
+ operationKind : 'query' ,
394
+ name : 'MyPreloadedQuery' ,
395
+ id : 'root-query-id' ,
396
+ text : null ,
397
+ metadata : { } ,
398
+ } ,
399
+ } ,
400
+ variables : {
401
+ id : params . id ,
402
+ } ,
403
+ } ,
404
+ } ,
405
+ entryPoints : {
406
+ myNestedEntryPoint : {
407
+ entryPoint : nestedEntryPoint ,
408
+ entryPointParams : {
409
+ id : 'nested-' + params . id ,
410
+ } ,
411
+ } ,
412
+ } ,
413
+ } ;
414
+ } ,
415
+ root : ( new FakeJSResource ( null ) : $FlowFixMe ) ,
416
+ } ;
417
+ const preloadedEntryPoint = loadEntryPoint (
418
+ {
419
+ getEnvironment : ( ) => env ,
420
+ } ,
421
+ entryPoint ,
422
+ { } ,
423
+ ) ;
424
+ const { dispose} = preloadedEntryPoint ;
425
+ const nestedEntryPointDisposeSpy = jest . spyOn (
426
+ preloadedEntryPoint . entryPoints . myNestedEntryPoint ,
427
+ 'dispose' ,
428
+ ) ;
429
+ expect ( dispose ) . toBeDefined ( ) ;
430
+ if ( dispose ) {
431
+ expect ( nestedEntryPointDisposeSpy ) . not . toHaveBeenCalled ( ) ;
432
+ dispose ( ) ;
433
+ expect ( nestedEntryPointDisposeSpy ) . toHaveBeenCalled ( ) ;
434
+ }
435
+ } ) ;
436
+
359
437
test ( 'with `getEnvironment` function' , ( ) => {
360
438
const env = createMockEnvironment ( ) ;
361
439
const networkSpy = jest . spyOn ( env . getNetwork ( ) , 'execute' ) ;
0 commit comments