Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 15e878c

Browse files
committedFeb 28, 2025··
Update SharedCacheControls test
1 parent 192d8de commit 15e878c

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed
 

‎packages/next/src/server/lib/incremental-cache/shared-cache-controls.test.ts

+29-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { PrerenderManifestRoute } from '../../../build'
1+
import type {
2+
DynamicPrerenderManifestRoute,
3+
PrerenderManifestRoute,
4+
} from '../../../build'
25
import { RenderingMode } from '../../../build/rendering-mode'
36
import { SharedCacheControls } from './shared-cache-controls'
47

@@ -30,7 +33,23 @@ describe('SharedCacheControls', () => {
3033
allowHeader: [],
3134
} satisfies PrerenderManifestRoute,
3235
},
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+
},
3453
}
3554
sharedCacheControls = new SharedCacheControls(prerenderManifest)
3655
})
@@ -40,7 +59,7 @@ describe('SharedCacheControls', () => {
4059
})
4160

4261
it('should get cache control from in-memory cache', () => {
43-
sharedCacheControls.set('/route1', { revalidate: 15 })
62+
sharedCacheControls.set('/route1', { revalidate: 15, expire: undefined })
4463
const cacheControl = sharedCacheControls.get('/route1')
4564
expect(cacheControl).toEqual({ revalidate: 15 })
4665
})
@@ -56,15 +75,20 @@ describe('SharedCacheControls', () => {
5675
})
5776

5877
it('should set cache control in cache', () => {
59-
sharedCacheControls.set('/route3', { revalidate: 30 })
78+
sharedCacheControls.set('/route3', { revalidate: 30, expire: undefined })
6079
const cacheControl = sharedCacheControls.get('/route3')
6180
expect(cacheControl).toEqual({ revalidate: 30 })
6281
})
6382

6483
it('should clear the in-memory cache', () => {
65-
sharedCacheControls.set('/route3', { revalidate: 30 })
84+
sharedCacheControls.set('/route3', { revalidate: 30, expire: undefined })
6685
sharedCacheControls.clear()
6786
const cacheControl = sharedCacheControls.get('/route3')
6887
expect(cacheControl).toBeUndefined()
6988
})
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+
})
7094
})

0 commit comments

Comments
 (0)
Please sign in to comment.