@@ -8,7 +8,7 @@ const basePrerenderManifest: PrerenderManifest = {
8
8
}
9
9
10
10
describe ( 'getRscDataRouter' , ( ) => {
11
- it ( 'should create a RSC data router when data routes are not present for routes ' , ( ) => {
11
+ it ( 'should filter static routes when creating the RSC data router ' , ( ) => {
12
12
const manifest : PrerenderManifest = {
13
13
...basePrerenderManifest ,
14
14
routes : {
@@ -37,4 +37,36 @@ describe('getRscDataRouter', () => {
37
37
38
38
expect ( typeof rscDataRouter ) . toBe ( 'function' )
39
39
} )
40
+
41
+ it ( 'should filter dynamic routes when creating the RSC data router' , ( ) => {
42
+ const manifest : PrerenderManifest = {
43
+ ...basePrerenderManifest ,
44
+ dynamicRoutes : {
45
+ '/[slug]' : {
46
+ routeRegex : '^\\/(?<slug>[^\\/]+?)(?:\\/)?$' ,
47
+ fallback : null ,
48
+ dataRoute : null ,
49
+ dataRouteRegex : '^\\/(?<slug>[^\\/]+?)(?:\\/)?$' ,
50
+ } ,
51
+ '/[slug]/[slug2]' : {
52
+ routeRegex : '^\\/(?<slug>[^\\/]+?)(?:\\/)(?<slug2>[^\\/]+?)(?:\\/)?$' ,
53
+ fallback : null ,
54
+ dataRoute : '/[slug]/[slug2].json.rsc' ,
55
+ dataRouteRegex : '^\\/(?<slug>[^\\/]+?)(?:\\/)(?<slug2>[^\\/]+?)(?:\\/)?$' ,
56
+ } ,
57
+ } ,
58
+ }
59
+
60
+ let rscDataRouter
61
+
62
+ // Normally type checking would pick this up, but because this file is copied when generating
63
+ // edge functions for the build, we need to make sure it's valid for builds.
64
+ //
65
+ // See https://github.com/netlify/next-runtime/issues/1940
66
+ expect ( ( ) => {
67
+ rscDataRouter = getRscDataRouter ( manifest )
68
+ } ) . not . toThrow ( )
69
+
70
+ expect ( typeof rscDataRouter ) . toBe ( 'function' )
71
+ } )
40
72
} )
0 commit comments