Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace got with node-fetch on redirects.test.ts #6234

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions tests/integration/commands/dev/redirects.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { describe, expect, test } from 'vitest'

import { FixtureTestContext, setupFixtureTests } from '../../utils/fixture.js'
import got from '../../utils/got.js'
import fetch from 'node-fetch'

describe('redirects', () => {
setupFixtureTests('dev-server-with-functions', { devServer: true }, () => {
test<FixtureTestContext>('should send original query params to functions', async ({ devServer }) => {
const response = await got(`http://localhost:${devServer.port}/with-params?param2=world&other=1`, {
throwHttpErrors: false,
retry: { limit: 0 },
})
const response = await fetch(`http://localhost:${devServer.port}/with-params?param2=world&other=1`, {})

expect(response.statusCode).toBe(200)
expect(response.status).toBe(200)

const result = JSON.parse(response.body)
const result = await response.json()
expect(result.queryStringParameters).not.toHaveProperty('param1')
expect(result.queryStringParameters).toHaveProperty('param2', 'world')
expect(result.queryStringParameters).toHaveProperty('other', '1')
Expand All @@ -22,14 +19,11 @@ describe('redirects', () => {
test<FixtureTestContext>('should send original query params to functions when using duplicate parameters', async ({
devServer,
}) => {
const response = await got(`http://localhost:${devServer.port}/api/echo?param=hello&param=world`, {
throwHttpErrors: false,
retry: { limit: 0 },
})
const response = await fetch(`http://localhost:${devServer.port}/api/echo?param=hello&param=world`, {})

expect(response.statusCode).toBe(200)
expect(response.status).toBe(200)

const result = JSON.parse(response.body)
const result = await response.json()
expect(result.queryStringParameters).toHaveProperty('param', 'hello, world')
expect(result.multiValueQueryStringParameters).toHaveProperty('param', ['hello', 'world'])
})
Expand Down
Loading