-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.js
48 lines (38 loc) · 846 Bytes
/
tools.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
/**
* User: jo
* Date: 13.05.13
* Time: 16:55
*
* Testing tools.js
*/
var tools = require('../lib/tools.js'),
crypto = require('crypto');
/**
* Test for tools
*/
describe('tools', function () {
/**
* Test for getHash
*/
describe('#getHash', function () {
var str = 'adfasfasfaf';
it('should be a md5 hash and return "hex"', function () {
var h1 = crypto.createHash('md5'),
h2 = tools.getHash();
h1 = h1.update(str).digest('hex');
h2 = h2.update(str).end();
h1.should.eql(h2);
});
});
/**
* Test for #getEndHeaderIndex
*/
describe('#getEndHeaderIndex', function () {
var raw = new Buffer('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n'),
last = raw.length - 4;
it('should return ' + last, function () {
var index = tools.getEndHeaderIndex(raw);
index.should.eql(last);
});
});
});