Skip to content

Commit fb9d7bf

Browse files
authored
test(context): assert case-insensitive header names in response helpers (#5116)
1 parent b2ae3a2 commit fb9d7bf

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎src/context.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,21 @@ describe('Context header', () => {
492492
})
493493
expect(res.headers.get('X-Test')).toBeNull()
494494
})
495+
496+
it('Should override the default Content-Type even if the header name casing differs', async () => {
497+
const res = c.json({ type: 'urn:example:error' }, 400, {
498+
'content-type': 'application/problem+json',
499+
})
500+
expect(res.headers.get('Content-Type')).toBe('application/problem+json')
501+
})
502+
503+
it('Should apply the last value when header names differ only in casing', async () => {
504+
const res = c.body('foo', 200, {
505+
'X-Custom': 'first',
506+
'x-custom': 'second',
507+
})
508+
expect(res.headers.get('X-Custom')).toBe('second')
509+
})
495510
})
496511

497512
describe('Pass a ResponseInit to respond methods', () => {

0 commit comments

Comments
 (0)