Skip to content

Commit

Permalink
Add test for multiple cookies coming from middleware (#34465)
Browse files Browse the repository at this point in the history
This PR adds a test that ensures that we can set multiple cookies in a middleware response
  • Loading branch information
Schniz committed Feb 18, 2022
1 parent 271dff5 commit e251a8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Expand Up @@ -32,6 +32,15 @@ export async function middleware(request, ev) {
return next
}

if (url.pathname === '/responses/two-cookies') {
const headers = new Headers()
headers.append('set-cookie', 'foo=chocochip')
headers.append('set-cookie', 'bar=chocochip')
return new Response('cookies set', {
headers,
})
}

// Streams a basic response
if (url.pathname === '/responses/stream-a-response') {
ev.waitUntil(
Expand Down
12 changes: 12 additions & 0 deletions test/integration/middleware/core/test/index.test.js
Expand Up @@ -473,6 +473,18 @@ function redirectTests(locale = '') {
}

function responseTests(locale = '') {
it(`${locale} responds with multiple cookies`, async () => {
const res = await fetchViaHTTP(
context.appPort,
`${locale}/responses/two-cookies`
)

expect(res.headers.raw()['set-cookie']).toEqual([
'foo=chocochip',
'bar=chocochip',
])
})

it(`${locale} should stream a response`, async () => {
const res = await fetchViaHTTP(
context.appPort,
Expand Down

0 comments on commit e251a8b

Please sign in to comment.