-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseHeaders.spec.ts
More file actions
35 lines (30 loc) · 932 Bytes
/
parseHeaders.spec.ts
File metadata and controls
35 lines (30 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import assert from 'assert'
import { describe, it } from 'node:test'
import { parseHeaders } from './parseHeaders.ts'
void describe('parseHeaders()', () => {
void it('should parse both lowercase and uppercase headers', () => {
const headers = {
'content-type': 'application/json',
'Content-Length': '1234',
'x-custom-header': 'value',
}
const parsedHeaders = parseHeaders(headers)
assert.deepEqual(
new Map(parsedHeaders.entries()),
new Map([
['content-type', 'application/json'],
['content-length', '1234'],
['x-custom-header', 'value'],
]),
)
})
void it('should handle null values in headers', () =>
assert.deepEqual(parseHeaders(null), new Map()))
void it('should make header keys case-insensitive', () => {
const headers = {
'x-custom-header': 'value',
}
const parsedHeaders = parseHeaders(headers)
assert.equal(parsedHeaders.get('X-Custom-HEADER'), 'value')
})
})