[test] passes/web.js (first 2 funcs)

This commit is contained in:
yawnt 2013-08-21 17:37:38 +02:00
parent 356f43d719
commit d40e4beb62
3 changed files with 37 additions and 6 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ node_modules
*.swp
cov
ttest.js
notes

View File

@ -7,11 +7,13 @@ describe('lib/caronte/common.js', function() {
var outgoing = {};
common.setupOutgoing(outgoing,
{
host : 'hey',
hostname : 'how',
socketPath: 'are',
port : 'you',
agent : '?'
target: {
host : 'hey',
hostname : 'how',
socketPath: 'are',
port : 'you',
agent : '?'
}
},
{
method : 'i',
@ -23,7 +25,7 @@ describe('lib/caronte/common.js', function() {
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.agent).to.eql('?');
expect(outgoing.method).to.eql('i');
expect(outgoing.path).to.eql('am');

View File

@ -0,0 +1,28 @@
var caronte = require('../lib/caronte/passes/web'),
expect = require('expect.js');
describe('lib/caronte/passes/web.js', function() {
describe('#deleteLength', function() {
it('should change `content-length`', function() {
var stubRequest = {
method: 'DELETE',
headers: {}
};
caronte.deleteLength(stubRequest, {}, {});
expect(stubRequest.headers['content-length']).to.eql('0');
})
});
describe('#timeout', function() {
it('should set timeout on the socket', function() {
var done = false, stubRequest = {
socket: {
setTimeout: function(value) { done = value; }
}
}
caronte.timeout(stubRequest, {}, { timeout: 5000});
expect(done).to.eql(5000);
});
});
});