mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[tests] add more tests
This commit is contained in:
parent
335af81d02
commit
cedc5c4bd2
@ -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);
|
||||
};
|
||||
@ -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"
|
||||
},
|
||||
|
||||
|
||||
33
test/lib-caronte-common-test.js
Normal file
33
test/lib-caronte-common-test.js
Normal 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')
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user