-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix NextRequest constructor parameters (#52001)
FIx the type change introduced in #51727
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @jest-environment @edge-runtime/jest-environment | ||
*/ | ||
|
||
import { expectTypeOf } from 'expect-type' | ||
import { NextRequest } from 'next/src/server/web/spec-extension/request' | ||
|
||
it('should have 1 required parameter for constructor', () => { | ||
expect(NextRequest.length).toBe(1) | ||
}) | ||
|
||
it('should allow the 2nd parameter to be undefined', () => { | ||
const request = new NextRequest('https://vercel.com') | ||
expectTypeOf(request).toMatchTypeOf<NextRequest>() | ||
|
||
expect( | ||
new NextRequest('https://vercel.com', { geo: { city: 'Mars' } }) | ||
).toHaveProperty('geo.city', 'Mars') | ||
expect(new NextRequest('https://vercel.com')).toHaveProperty( | ||
'nextUrl.pathname', | ||
'/' | ||
) | ||
}) |