1
- import type { PrerenderManifestRoute } from '../../../build'
1
+ import type {
2
+ DynamicPrerenderManifestRoute ,
3
+ PrerenderManifestRoute ,
4
+ } from '../../../build'
2
5
import { RenderingMode } from '../../../build/rendering-mode'
3
6
import { SharedCacheControls } from './shared-cache-controls'
4
7
@@ -30,7 +33,23 @@ describe('SharedCacheControls', () => {
30
33
allowHeader : [ ] ,
31
34
} satisfies PrerenderManifestRoute ,
32
35
} ,
33
- dynamicRoutes : { } ,
36
+ dynamicRoutes : {
37
+ '/route4' : {
38
+ fallbackRevalidate : 30 ,
39
+ fallbackExpire : 50 ,
40
+ fallback : true ,
41
+ fallbackRootParams : undefined ,
42
+ fallbackSourceRoute : undefined ,
43
+ dataRoute : null ,
44
+ dataRouteRegex : null ,
45
+ prefetchDataRoute : null ,
46
+ prefetchDataRouteRegex : null ,
47
+ routeRegex : '' ,
48
+ experimentalPPR : undefined ,
49
+ renderingMode : RenderingMode . PARTIALLY_STATIC ,
50
+ allowHeader : [ ] ,
51
+ } satisfies DynamicPrerenderManifestRoute ,
52
+ } ,
34
53
}
35
54
sharedCacheControls = new SharedCacheControls ( prerenderManifest )
36
55
} )
@@ -40,7 +59,7 @@ describe('SharedCacheControls', () => {
40
59
} )
41
60
42
61
it ( 'should get cache control from in-memory cache' , ( ) => {
43
- sharedCacheControls . set ( '/route1' , { revalidate : 15 } )
62
+ sharedCacheControls . set ( '/route1' , { revalidate : 15 , expire : undefined } )
44
63
const cacheControl = sharedCacheControls . get ( '/route1' )
45
64
expect ( cacheControl ) . toEqual ( { revalidate : 15 } )
46
65
} )
@@ -56,15 +75,20 @@ describe('SharedCacheControls', () => {
56
75
} )
57
76
58
77
it ( 'should set cache control in cache' , ( ) => {
59
- sharedCacheControls . set ( '/route3' , { revalidate : 30 } )
78
+ sharedCacheControls . set ( '/route3' , { revalidate : 30 , expire : undefined } )
60
79
const cacheControl = sharedCacheControls . get ( '/route3' )
61
80
expect ( cacheControl ) . toEqual ( { revalidate : 30 } )
62
81
} )
63
82
64
83
it ( 'should clear the in-memory cache' , ( ) => {
65
- sharedCacheControls . set ( '/route3' , { revalidate : 30 } )
84
+ sharedCacheControls . set ( '/route3' , { revalidate : 30 , expire : undefined } )
66
85
sharedCacheControls . clear ( )
67
86
const cacheControl = sharedCacheControls . get ( '/route3' )
68
87
expect ( cacheControl ) . toBeUndefined ( )
69
88
} )
89
+
90
+ it ( 'should get cache control from prerender manifest for dynamic route with fallback' , ( ) => {
91
+ const cacheControl = sharedCacheControls . get ( '/route4' )
92
+ expect ( cacheControl ) . toEqual ( { revalidate : 30 , expire : 50 } )
93
+ } )
70
94
} )
0 commit comments