11import { generateRoutes } from './routes' ;
22
33describe ( 'generateRoutes' , ( ) => {
4- it ( 'should not generate static routes' , ( ) => {
4+ it ( 'should generate static routes' , ( ) => {
55 const staticRoutes = [ 'api/foo.rs' , 'api/bar/baz.rs' ] ;
66
7- expect ( generateRoutes ( staticRoutes ) ) . toEqual ( [ ] ) ;
7+ expect ( generateRoutes ( staticRoutes ) ) . toMatchInlineSnapshot ( `
8+ [
9+ {
10+ "dest": "/api/bar/baz",
11+ "path": "api/bar/baz",
12+ "src": "/api/bar/baz",
13+ },
14+ {
15+ "dest": "/api/foo",
16+ "path": "api/foo",
17+ "src": "/api/foo",
18+ },
19+ ]
20+ ` ) ;
821 } ) ;
922
1023 it ( 'should generate dynamic routes' , ( ) => {
@@ -16,12 +29,12 @@ describe('generateRoutes', () => {
1629 expect ( generateRoutes ( dynamicRoutes ) ) . toMatchInlineSnapshot ( `
1730 [
1831 {
19- "dest": "api/post/[id]/comments/[commentId]?id=$id&commentId=$commentId",
32+ "dest": "/ api/post/[id]/comments/[commentId]?id=$id&commentId=$commentId",
2033 "path": "api/post/[id]/comments/[commentId]",
2134 "src": "/api/post/(?<id>[^/]+)/comments/(?<commentId>[^/]+)",
2235 },
2336 {
24- "dest": "api/post/[id]?id=$id",
37+ "dest": "/ api/post/[id]?id=$id",
2538 "path": "api/post/[id]",
2639 "src": "/api/post/(?<id>[^/]+)",
2740 },
@@ -39,17 +52,17 @@ describe('generateRoutes', () => {
3952 expect ( generateRoutes ( catchAllRoutes ) ) . toMatchInlineSnapshot ( `
4053 [
4154 {
42- "dest": "api/all/[...all]",
55+ "dest": "/ api/all/[...all]",
4356 "path": "api/all/[...all]",
4457 "src": "/api/all/(\\S+)",
4558 },
4659 {
47- "dest": "api/optional/[[...id]]",
60+ "dest": "/ api/optional/[[...id]]",
4861 "path": "api/optional/[[...id]]",
4962 "src": "/api/optional/(/\\S+)?",
5063 },
5164 {
52- "dest": "api/[...rootAll]",
65+ "dest": "/ api/[...rootAll]",
5366 "path": "api/[...rootAll]",
5467 "src": "/api/(\\S+)",
5568 },
@@ -69,27 +82,27 @@ describe('generateRoutes', () => {
6982 expect ( generateRoutes ( allRoutes ) ) . toMatchInlineSnapshot ( `
7083 [
7184 {
72- "dest": "api/post/[id]/comments/[commentId]?id=$id&commentId=$commentId",
85+ "dest": "/ api/post/[id]/comments/[commentId]?id=$id&commentId=$commentId",
7386 "path": "api/post/[id]/comments/[commentId]",
7487 "src": "/api/post/(?<id>[^/]+)/comments/(?<commentId>[^/]+)",
7588 },
7689 {
77- "dest": "api/post/[id]?id=$id",
90+ "dest": "/ api/post/[id]?id=$id",
7891 "path": "api/post/[id]",
7992 "src": "/api/post/(?<id>[^/]+)",
8093 },
8194 {
82- "dest": "api/all/[...all]",
95+ "dest": "/ api/all/[...all]",
8396 "path": "api/all/[...all]",
8497 "src": "/api/all/(\\S+)",
8598 },
8699 {
87- "dest": "api/optional/[[...id]]",
100+ "dest": "/ api/optional/[[...id]]",
88101 "path": "api/optional/[[...id]]",
89102 "src": "/api/optional/(/\\S+)?",
90103 },
91104 {
92- "dest": "api/[...rootAll]",
105+ "dest": "/ api/[...rootAll]",
93106 "path": "api/[...rootAll]",
94107 "src": "/api/(\\S+)",
95108 },
0 commit comments