Skip to content

Commit

Permalink
Merge branch 'main' into refactor/replace-got/v2-api.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
hereje authored Dec 8, 2023
2 parents 2757eaf + f9c07bc commit a7e6f89
Showing 1 changed file with 7 additions and 13 deletions.
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

0 comments on commit a7e6f89

Please sign in to comment.