forked from madglory/edgescape-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
45 lines (32 loc) · 804 Bytes
/
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
'use strict';
var assert = require('assert');
var edgescapeParser = require('./');
it('parses header into an object', function(done) {
var req = {
headers: {
'x-akamai-edgescape': 'key1=val1,key2=val2,key3=val3,asnum=3+4+5,area_code=100-200+300-400'
}
};
var expectedObject = {
key1: 'val1',
key2: 'val2',
key3: 'val3',
asnum: [3,4,5],
area_code: ['100-200','300-400']
};
edgescapeParser()(req, {}, function() {
assert(req.akamai);
assert(req.akamai.edgescape);
assert.deepEqual(req.akamai.edgescape, expectedObject);
done();
});
});
it('moves along if no header is available', function(done) {
var req = {
headers: {}
};
edgescapeParser()(req, {}, function() {
assert.equal(req.akamai, undefined);
done();
});
});