-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathrsc-data.spec.ts
40 lines (35 loc) · 1.13 KB
/
rsc-data.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { getRscDataRouter, PrerenderManifest } from '../packages/runtime/src/templates/edge-shared/rsc-data'
const basePrerenderManifest: PrerenderManifest = {
version: 3,
routes: {},
dynamicRoutes: {},
notFoundRoutes: [],
}
describe('getRscDataRouter', () => {
it('should create a RSC data router when data routes are not present for routes', () => {
const manifest: PrerenderManifest = {
...basePrerenderManifest,
routes: {
'/': {
initialRevalidateSeconds: 1,
srcRoute: null,
dataRoute: '/index.json.rsc',
},
'/api/hello': {
initialRevalidateSeconds: false,
srcRoute: '/api/hello',
dataRoute: null,
},
},
}
let rscDataRouter
// Normally type checking would pick this up, but because this file is copied when generating
// edge functions for the build, we need to make sure it's valid for builds.
//
// See https://github.com/netlify/next-runtime/issues/1940
expect(() => {
rscDataRouter = getRscDataRouter(manifest)
}).not.toThrow()
expect(typeof rscDataRouter).toBe('function')
})
})