Skip to content

Commit cedc5c4

Browse files
committed
[tests] add more tests
1 parent 335af81 commit cedc5c4

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

Diff for: lib/caronte/streams/forward.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ module.exports = ForwardStream;
2121
*/
2222

2323
function ForwardStream() {
24+
var self = this;
25+
2426
Writable.call(this);
2527

26-
this.once('pipe', this.onPipe);
27-
this.once('finish', this.onFinish);
28+
this.once('pipe', function() { self.onPipe() });
29+
this.once('finish', function() { self.onFinish() });
2830
}
2931

32+
require('util').inherits(ForwardStream, Writable);
33+
3034
/**
3135
* Fires up the request to the external target
3236
*
@@ -74,6 +78,4 @@ ForwardStream.prototype.onFinish = function() {
7478

7579
ForwardStream.prototype._write = function(chunk, encoding, clb) {
7680
this.forwardReq.write(chunk, encoding, clb);
77-
};
78-
79-
require('util').inherits(ForwardStream, Writable);
81+
};

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"scripts" : {
2121
"blanket" : { "pattern": "caronte/lib" },
22-
"test" : "mocha -R spec test/*-test.js && npm run-script test-cov",
22+
"test" : "mocha -R landing test/*-test.js",
2323
"test-cov" : "mocha --require blanket -R html-cov > cov/coverage.html"
2424
},
2525

Diff for: test/lib-caronte-common-test.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var common = require('../lib/caronte/common'),
2+
expect = require('expect.js');
3+
4+
describe('lib/caronte/common.js', function() {
5+
describe('#setupOutgoing', function() {
6+
it('should setup the right headers', function() {
7+
var outgoing = {};
8+
common.setupOutgoing(outgoing,
9+
{
10+
host : 'hey',
11+
hostname : 'how',
12+
socketPath: 'are',
13+
port : 'you',
14+
agent : '?'
15+
},
16+
{
17+
method : 'i',
18+
path : 'am',
19+
headers : 'proxy'
20+
});
21+
22+
expect(outgoing.host).to.eql('hey');
23+
expect(outgoing.hostname).to.eql('how');
24+
expect(outgoing.socketPath).to.eql('are');
25+
expect(outgoing.port).to.eql('you');
26+
expect(outgoing.agent).to.eql('?');
27+
28+
expect(outgoing.method).to.eql('i');
29+
expect(outgoing.path).to.eql('am');
30+
expect(outgoing.headers).to.eql('proxy')
31+
});
32+
});
33+
});

0 commit comments

Comments
 (0)