add a test that verifies that NextResponse can be cloned (#37883)
This resolves #35573 I can't seem to reproduce the issue so I only created a unit test that verifies that it has the correct behavior. @tavvy can you also check this PR out to see if it makes sense or not? ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md`
This commit is contained in:
parent
ee7648ae0a
commit
ff55e4a7f3
1 changed files with 10 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
|||
* @jest-environment @edge-runtime/jest-environment
|
||||
*/
|
||||
|
||||
import { NextResponse } from 'next/dist/server/web/spec-extension/response'
|
||||
import { NextResponse } from 'next/server/web/spec-extension/response'
|
||||
|
||||
const toJSON = async (response) => ({
|
||||
body: await response.json(),
|
||||
|
@ -44,3 +44,12 @@ it('automatically parses and formats JSON', async () => {
|
|||
body: '',
|
||||
})
|
||||
})
|
||||
|
||||
it('can be cloned', async () => {
|
||||
const fetchResponse = await fetch('https://example.vercel.sh')
|
||||
const newResponse = new NextResponse(fetchResponse.body, fetchResponse)
|
||||
expect(await newResponse.text()).toContain('Example Domain')
|
||||
expect(Object.fromEntries(newResponse.headers)).toMatchObject({
|
||||
server: 'Vercel',
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue