Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Oct 25, 2021
1 parent fd15cdf commit e92409e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/integration/middleware-core/pages/responses/_middleware.js
Expand Up @@ -10,15 +10,14 @@ export async function middleware(request, ev) {
const encoder = new TextEncoder()
const next = NextResponse.next()

// Sends a header
if (url.pathname === '/responses/header') {
next.headers.set('x-first-header', 'valid')
return next
}

// Header based on query param
if (url.searchParams.get('nested-header') === 'true') {
next.headers.set('x-nested-header', 'valid')
}

// Sends a header
if (url.pathname === '/responses/header') {
next.headers.set('x-first-header', 'valid')
return next
}

Expand Down
9 changes: 9 additions & 0 deletions test/integration/middleware-core/test/index.test.js
Expand Up @@ -309,6 +309,15 @@ function responseTests(locale = '') {
expect($('.title').text()).toBe('Hello World')
})

it(`${locale} should respond with 2 nested headers`, async () => {
const res = await fetchViaHTTP(
context.appPort,
`${locale}/responses/header?nested-header=true`
)
expect(res.headers.get('x-first-header')).toBe('valid')
expect(res.headers.get('x-nested-header')).toBe('valid')
})

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

0 comments on commit e92409e

Please sign in to comment.