-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.js
70 lines (63 loc) · 1.6 KB
/
test.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var test = require('tape')
, parse = require('./parse-headers')
, headers1 = [
''
, 'Date: Sun, 17 Aug 2014 16:24:52 GMT'
, 'Content-Type: text/html; charset=utf-8'
, 'Transfer-Encoding: chunked'
, ''
]
, headers2 = [
''
, 'Date: Sun, 17 Aug 2014 16:24:52 GMT'
, 'Content-Type: text/html; charset=utf-8'
, 'Transfer-Encoding: chunked'
, 'Set-Cookie: Foo'
, 'set-Cookie: bar'
, 'set-cookie: bong'
]
test('sanity check', function (t) {
t.deepEqual(parse(), {})
t.deepEqual(parse(''), {})
t.end()
})
test('simple', function (t) {
t.deepEqual(
parse(headers1.join('\r\n'))
, {
date: 'Sun, 17 Aug 2014 16:24:52 GMT'
, 'content-type': 'text/html; charset=utf-8'
, 'transfer-encoding': 'chunked'
}
)
t.deepEqual(
parse(headers1.join('\n'))
, {
date: 'Sun, 17 Aug 2014 16:24:52 GMT'
, 'content-type': 'text/html; charset=utf-8'
, 'transfer-encoding': 'chunked'
}
)
t.end()
})
test('duplicate keys', function (t) {
t.deepEqual(
parse(headers2.join('\r\n'))
, {
date: 'Sun, 17 Aug 2014 16:24:52 GMT'
, 'content-type': 'text/html; charset=utf-8'
, 'transfer-encoding': 'chunked'
, 'set-cookie': [ 'Foo', 'bar', 'bong' ]
}
)
t.deepEqual(
parse(headers2.join('\n'))
, {
date: 'Sun, 17 Aug 2014 16:24:52 GMT'
, 'content-type': 'text/html; charset=utf-8'
, 'transfer-encoding': 'chunked'
, 'set-cookie': [ 'Foo', 'bar', 'bong' ]
}
)
t.end()
})