/
urlencoded.js
39 lines (32 loc) · 952 Bytes
/
urlencoded.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var connect = require('../')
, should = require('./shared');
var app = connect();
app.use(connect.urlencoded());
app.use(function(req, res){
res.end(JSON.stringify(req.body));
});
describe('connect.urlencoded()', function(){
should['default request body'](app);
should['limit body to']('1mb', 'application/x-www-form-urlencoded', app);
it('should support all http methods', function(done){
app.request()
.get('/')
.set('Content-Type', 'application/x-www-form-urlencoded')
.set('Content-Length', 'user=tobi'.length)
.write('user=tobi')
.end(function(res){
res.body.should.equal('{"user":"tobi"}');
done();
});
})
it('should parse x-www-form-urlencoded', function(done){
app.request()
.post('/')
.set('Content-Type', 'application/x-www-form-urlencoded')
.write('user=tobi')
.end(function(res){
res.body.should.equal('{"user":"tobi"}');
done();
});
})
})