Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Nov 17, 2011
1 parent 01bd648 commit 3c2978b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/middleware/bodyParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ exports.parse['multipart/form-data'] = function(req, fn){
form.on('error', fn);

form.on('end', function(){
console.log(body);
req.body = body;
fn();
});
Expand Down
13 changes: 6 additions & 7 deletions test/bodyParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ var app = connect();
app.use(connect.bodyParser());

app.use(function(req, res){
res.end(req.body.user);
res.end(JSON.stringify(req.body));
});

describe('connect.bodyParser()', function(){
it('should default to {}', function(done){
app.request()
.post('/')
.end(function(res){
res.body.should.equal('');
res.body.should.equal('{}');
done();
})
})
Expand All @@ -25,7 +25,7 @@ describe('connect.bodyParser()', function(){
.set('Content-Type', 'application/json')
.write('{"user":"tobi"}')
.end(function(res){
res.body.should.equal('tobi');
res.body.should.equal('{"user":"tobi"}');
done();
});
})
Expand All @@ -36,7 +36,7 @@ describe('connect.bodyParser()', function(){
.set('Content-Type', 'application/x-www-form-urlencoded')
.write('user=tobi')
.end(function(res){
res.body.should.equal('tobi');
res.body.should.equal('{"user":"tobi"}');
done();
});
})
Expand All @@ -47,13 +47,12 @@ describe('connect.bodyParser()', function(){
.post('/')
.set('Content-Type', 'multipart/form-data; boundary=foo')
.write('--foo\r\n')
.write('Content-Disposition: form-data; name="name"\r\n')
.write('Content-Disposition: form-data; name="user"\r\n')
.write('\r\n')
.write('Tobi')
.write('\r\n--foo--')
.end(function(res){
console.log(res.body);
res.body.should.equal('tobi');
res.body.should.equal('{"user":"Tobi"}');
done();
});
})
Expand Down

0 comments on commit 3c2978b

Please sign in to comment.