Security update for permissions_by_term
[yaffs-website] / node_modules / parse-headers / test.js
1 var test = require('tape')
2   , parse = require('./parse-headers')
3
4   , headers1 = [
5         ''
6       , 'Date: Sun, 17 Aug 2014 16:24:52 GMT'
7       , 'Content-Type: text/html; charset=utf-8'
8       , 'Transfer-Encoding: chunked'
9       , ''
10     ]
11   , headers2 = [
12         ''
13       , 'Date: Sun, 17 Aug 2014 16:24:52 GMT'
14       , 'Content-Type: text/html; charset=utf-8'
15       , 'Transfer-Encoding: chunked'
16       , 'Set-Cookie: Foo'
17       , 'set-Cookie: bar'
18       , 'set-cookie: bong'
19     ]
20
21 test('sanity check', function (t) {
22
23   t.deepEqual(parse(), {})
24   t.deepEqual(parse(''), {})
25   t.end()
26 })
27
28 test('simple', function (t) {
29   t.deepEqual(
30       parse(headers1.join('\r\n'))
31     , {
32           date: 'Sun, 17 Aug 2014 16:24:52 GMT'
33         , 'content-type': 'text/html; charset=utf-8'
34         , 'transfer-encoding': 'chunked'
35       }
36   )
37   t.deepEqual(
38       parse(headers1.join('\n'))
39     , {
40           date: 'Sun, 17 Aug 2014 16:24:52 GMT'
41         , 'content-type': 'text/html; charset=utf-8'
42         , 'transfer-encoding': 'chunked'
43       }
44   )
45
46   t.end()
47 })
48
49 test('duplicate keys', function (t) {
50   t.deepEqual(
51       parse(headers2.join('\r\n'))
52     , {
53           date: 'Sun, 17 Aug 2014 16:24:52 GMT'
54         , 'content-type': 'text/html; charset=utf-8'
55         , 'transfer-encoding': 'chunked'
56         , 'set-cookie': [ 'Foo', 'bar', 'bong' ]
57       }
58   )
59   t.deepEqual(
60       parse(headers2.join('\n'))
61     , {
62           date: 'Sun, 17 Aug 2014 16:24:52 GMT'
63         , 'content-type': 'text/html; charset=utf-8'
64         , 'transfer-encoding': 'chunked'
65         , 'set-cookie': [ 'Foo', 'bar', 'bong' ]
66       }
67   )
68
69   t.end()
70 })