Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e59829

Browse files
committed
add failing test for route handlers (not implemented yet)
1 parent 19c8149 commit 0e59829

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { lang, locale } from 'next/root-params'
2+
3+
export async function GET() {
4+
return Response.json(
5+
// TODO(root-params): We're missing some wiring to set `requestStore.rootParams`,
6+
// so both of these will currently return undefined
7+
JSON.stringify({ lang: await lang(), locale: await locale() })
8+
)
9+
}

test/e2e/app-dir/app-root-params-getters/simple.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,17 @@ describe('app-root-param-getters - simple', () => {
2222
await assertNoRedbox(browser)
2323
}
2424
})
25+
26+
// root params currently don't work in route handlers.
27+
it.failing(
28+
'should allow reading root params in a route handler',
29+
async () => {
30+
const params = { lang: 'en', locale: 'us' }
31+
const response = await next.fetch(
32+
`/${params.lang}/${params.locale}/route-handler`
33+
)
34+
expect(response.status).toBe(200)
35+
expect(await response.json()).toEqual(params)
36+
}
37+
)
2538
})

0 commit comments

Comments
 (0)