[tests] add more tests

This commit is contained in:
yawnt 2013-08-09 19:13:44 +02:00
parent 335af81d02
commit cedc5c4bd2
3 changed files with 41 additions and 6 deletions

View File

@ -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
*
@ -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);
};

View File

@ -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"
},

View File

@ -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')
});
});
});