Skip to content

Commit

Permalink
[test] passes/web.js (first 2 funcs)
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Aug 21, 2013
1 parent 356f43d commit d40e4be
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
*.swp
cov
ttest.js
notes
14 changes: 8 additions & 6 deletions test/lib-caronte-common-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');
Expand Down
28 changes: 28 additions & 0 deletions test/lib-caronte-passes-web-test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
});

0 comments on commit d40e4be

Please sign in to comment.