mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[tests] fixed according new refactor and added test to common.setupSocket()
This commit is contained in:
parent
5bb83b967e
commit
1cb967b90a
@ -1,9 +1,9 @@
|
|||||||
var common = require('../lib/caronte/common'),
|
var common = require('../lib/caronte/common'),
|
||||||
expect = require('expect.js');
|
expect = require('expect.js');
|
||||||
|
|
||||||
describe('lib/caronte/common.js', function() {
|
describe('lib/caronte/common.js', function () {
|
||||||
describe('#setupOutgoing', function() {
|
describe('#setupOutgoing', function () {
|
||||||
it('should setup the right headers', function() {
|
it('should setup the correct headers', function () {
|
||||||
var outgoing = {};
|
var outgoing = {};
|
||||||
common.setupOutgoing(outgoing,
|
common.setupOutgoing(outgoing,
|
||||||
{
|
{
|
||||||
@ -17,7 +17,7 @@ describe('lib/caronte/common.js', function() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
method : 'i',
|
method : 'i',
|
||||||
path : 'am',
|
url : 'am',
|
||||||
headers : 'proxy'
|
headers : 'proxy'
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -25,11 +25,67 @@ describe('lib/caronte/common.js', function() {
|
|||||||
expect(outgoing.hostname).to.eql('how');
|
expect(outgoing.hostname).to.eql('how');
|
||||||
expect(outgoing.socketPath).to.eql('are');
|
expect(outgoing.socketPath).to.eql('are');
|
||||||
expect(outgoing.port).to.eql('you');
|
expect(outgoing.port).to.eql('you');
|
||||||
//expect(outgoing.agent).to.eql('?');
|
expect(outgoing.agent).to.eql('?');
|
||||||
|
|
||||||
expect(outgoing.method).to.eql('i');
|
expect(outgoing.method).to.eql('i');
|
||||||
expect(outgoing.path).to.eql('am');
|
expect(outgoing.path).to.eql('am');
|
||||||
expect(outgoing.headers).to.eql('proxy')
|
expect(outgoing.headers).to.eql('proxy')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('set the port according to the protocol', function () {
|
||||||
|
var outgoing = {};
|
||||||
|
common.setupOutgoing(outgoing,
|
||||||
|
{
|
||||||
|
target: {
|
||||||
|
host : 'how',
|
||||||
|
hostname : 'are',
|
||||||
|
socketPath: 'you',
|
||||||
|
agent : '?',
|
||||||
|
protocol: 'https:'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method : 'i',
|
||||||
|
url : 'am',
|
||||||
|
headers : 'proxy'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(outgoing.host).to.eql('how');
|
||||||
|
expect(outgoing.hostname).to.eql('are');
|
||||||
|
expect(outgoing.socketPath).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')
|
||||||
|
|
||||||
|
expect(outgoing.port).to.eql(443);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#setupSocket', function () {
|
||||||
|
it('should setup a socket', function () {
|
||||||
|
var socketConfig = {
|
||||||
|
timeout: null,
|
||||||
|
nodelay: false,
|
||||||
|
keepalive: false
|
||||||
|
},
|
||||||
|
stubSocket = {
|
||||||
|
setTimeout: function (num) {
|
||||||
|
socketConfig.timeout = num;
|
||||||
|
},
|
||||||
|
setNoDelay: function (bol) {
|
||||||
|
socketConfig.nodelay = bol;
|
||||||
|
},
|
||||||
|
setKeepAlive: function (bol) {
|
||||||
|
socketConfig.keepalive = bol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
returnValue = common.setupSocket(stubSocket);
|
||||||
|
|
||||||
|
expect(socketConfig.timeout).to.eql(0);
|
||||||
|
expect(socketConfig.nodelay).to.eql(true);
|
||||||
|
expect(socketConfig.keepalive).to.eql(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user