Skip to content

Commit a52411b

Browse files
committed
fix: imports
1 parent a392a38 commit a52411b

File tree

1 file changed

+55
-58
lines changed

1 file changed

+55
-58
lines changed

test/helpers/utils.spec.ts

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Chance from 'chance'
2-
import { ExperimentalConfig } from 'next/dist/server/config-shared'
32
import type { PrerenderManifest } from 'next/dist/build'
4-
import { generateDynamicRewrites } from '../../packages/runtime/src/helpers/redirects'
3+
import { ExperimentalConfig } from 'next/dist/server/config-shared'
54

5+
import { generateDynamicRewrites } from '../../packages/runtime/src/helpers/redirects'
66
import {
77
getCustomImageResponseHeaders,
88
getRemotePatterns,
@@ -20,24 +20,24 @@ const basePrerenderManifest: PrerenderManifest = {
2020
const prerenderManifest: PrerenderManifest = {
2121
...basePrerenderManifest,
2222
dynamicRoutes: {
23-
"/getStaticProps/[id]": {
24-
"routeRegex": "^/getStaticProps/([^/]+?)(?:/)?$",
25-
"dataRoute": "/_next/data/build-id/getStaticProps/[id].json",
26-
"fallback": false,
27-
"dataRouteRegex": "^/_next/data/build\\-id/getStaticProps/([^/]+?)\\.json$"
28-
},
23+
'/getStaticProps/[id]': {
24+
routeRegex: '^/getStaticProps/([^/]+?)(?:/)?$',
25+
dataRoute: '/_next/data/build-id/getStaticProps/[id].json',
26+
fallback: false,
27+
dataRouteRegex: '^/_next/data/build\\-id/getStaticProps/([^/]+?)\\.json$',
28+
},
2929
},
3030
}
3131

3232
const dynamicRoutes = [
3333
{
34-
"page": "/getStaticProps/[id]",
35-
"regex": "^/getStaticProps/([^/]+?)(?:/)?$",
36-
"routeKeys": {
37-
"nextParamid": "nextParamid"
34+
page: '/getStaticProps/[id]',
35+
regex: '^/getStaticProps/([^/]+?)(?:/)?$',
36+
routeKeys: {
37+
nextParamid: 'nextParamid',
3838
},
39-
"namedRegex": "^/getStaticProps/(?<nextParamid>[^/]+?)(?:/)?$"
40-
},
39+
namedRegex: '^/getStaticProps/(?<nextParamid>[^/]+?)(?:/)?$',
40+
},
4141
]
4242

4343
const route = {
@@ -176,23 +176,22 @@ describe('redirectsForNext404Route', () => {
176176
})
177177

178178
it('returns static 404 redirects when LEGACY_FALLBACK_FALSE is not set', async () => {
179-
180179
const expected = {
181-
"dynamicRewrites": [
180+
dynamicRewrites: [
182181
{
183-
"force": false,
184-
"from": "/_next/data/test/getStaticProps/:id.json",
185-
"status": 404,
186-
"to": "/server/pages/404.html",
187-
},
182+
force: false,
183+
from: '/_next/data/test/getStaticProps/:id.json',
184+
status: 404,
185+
to: '/server/pages/404.html',
186+
},
188187
{
189-
"force": false,
190-
"from": "/getStaticProps/:id",
191-
"status": 404,
192-
"to": "/server/pages/404.html",
193-
}
194-
],
195-
"dynamicRoutesThatMatchMiddleware": []
188+
force: false,
189+
from: '/getStaticProps/:id',
190+
status: 404,
191+
to: '/server/pages/404.html',
192+
},
193+
],
194+
dynamicRoutesThatMatchMiddleware: [],
196195
}
197196

198197
expect(generateDynamicRewrites(route)).toStrictEqual(expected)
@@ -202,21 +201,21 @@ describe('redirectsForNext404Route', () => {
202201
process.env.LEGACY_FALLBACK_FALSE = 'true'
203202

204203
const expected = {
205-
"dynamicRewrites": [
204+
dynamicRewrites: [
206205
{
207-
"force": false,
208-
"from": "/_next/data/test/getStaticProps/:id.json",
209-
"status": 200,
210-
"to": "/.netlify/builders/___netlify-odb-handler",
211-
},
206+
force: false,
207+
from: '/_next/data/test/getStaticProps/:id.json',
208+
status: 200,
209+
to: '/.netlify/builders/___netlify-odb-handler',
210+
},
212211
{
213-
"force": false,
214-
"from": "/getStaticProps/:id",
215-
"status": 200,
216-
"to": "/.netlify/builders/___netlify-odb-handler",
217-
}
218-
],
219-
"dynamicRoutesThatMatchMiddleware": []
212+
force: false,
213+
from: '/getStaticProps/:id',
214+
status: 200,
215+
to: '/.netlify/builders/___netlify-odb-handler',
216+
},
217+
],
218+
dynamicRoutesThatMatchMiddleware: [],
220219
}
221220

222221
expect(generateDynamicRewrites(route)).toStrictEqual(expected)
@@ -225,27 +224,25 @@ describe('redirectsForNext404Route', () => {
225224
it('returns static 404 redirects when LEGACY_FALLBACK_FALSE is set as "false"', async () => {
226225
// testing to make sure that the any other string other than 'true' still returns the static 404 redirects
227226
process.env.LEGACY_FALLBACK_FALSE = 'false'
228-
227+
229228
const expected = {
230-
"dynamicRewrites": [
229+
dynamicRewrites: [
231230
{
232-
"force": false,
233-
"from": "/_next/data/test/getStaticProps/:id.json",
234-
"status": 404,
235-
"to": "/server/pages/404.html",
236-
},
231+
force: false,
232+
from: '/_next/data/test/getStaticProps/:id.json',
233+
status: 404,
234+
to: '/server/pages/404.html',
235+
},
237236
{
238-
"force": false,
239-
"from": "/getStaticProps/:id",
240-
"status": 404,
241-
"to": "/server/pages/404.html",
242-
}
243-
],
244-
"dynamicRoutesThatMatchMiddleware": []
237+
force: false,
238+
from: '/getStaticProps/:id',
239+
status: 404,
240+
to: '/server/pages/404.html',
241+
},
242+
],
243+
dynamicRoutesThatMatchMiddleware: [],
245244
}
246-
245+
247246
expect(generateDynamicRewrites(route)).toStrictEqual(expected)
248247
})
249248
})
250-
251-

0 commit comments

Comments
 (0)