Skip to content

Commit

Permalink
[tests] add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Aug 9, 2013
1 parent 335af81 commit cedc5c4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
12 changes: 7 additions & 5 deletions lib/caronte/streams/forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ module.exports = ForwardStream;
*/

function ForwardStream() {
var self = this;

Writable.call(this);

this.once('pipe', this.onPipe);
this.once('finish', this.onFinish);
this.once('pipe', function() { self.onPipe() });
this.once('finish', function() { self.onFinish() });
}

require('util').inherits(ForwardStream, Writable);

/**
* Fires up the request to the external target
*
Expand Down Expand Up @@ -74,6 +78,4 @@ ForwardStream.prototype.onFinish = function() {

ForwardStream.prototype._write = function(chunk, encoding, clb) {
this.forwardReq.write(chunk, encoding, clb);
};

require('util').inherits(ForwardStream, Writable);
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"scripts" : {
"blanket" : { "pattern": "caronte/lib" },
"test" : "mocha -R spec test/*-test.js && npm run-script test-cov",
"test" : "mocha -R landing test/*-test.js",
"test-cov" : "mocha --require blanket -R html-cov > cov/coverage.html"
},

Expand Down
33 changes: 33 additions & 0 deletions test/lib-caronte-common-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var common = require('../lib/caronte/common'),
expect = require('expect.js');

describe('lib/caronte/common.js', function() {
describe('#setupOutgoing', function() {
it('should setup the right headers', function() {
var outgoing = {};
common.setupOutgoing(outgoing,
{
host : 'hey',
hostname : 'how',
socketPath: 'are',
port : 'you',
agent : '?'
},
{
method : 'i',
path : 'am',
headers : 'proxy'
});

expect(outgoing.host).to.eql('hey');
expect(outgoing.hostname).to.eql('how');
expect(outgoing.socketPath).to.eql('are');
expect(outgoing.port).to.eql('you');
expect(outgoing.agent).to.eql('?');

expect(outgoing.method).to.eql('i');
expect(outgoing.path).to.eql('am');
expect(outgoing.headers).to.eql('proxy')
});
});
});

0 comments on commit cedc5c4

Please sign in to comment.