mirror of
https://github.com/koajs/examples.git
synced 2026-02-01 15:56:57 +00:00
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
var app = require('./app');
|
|
var request = require('supertest').agent(app.listen());
|
|
|
|
describe('Body Parsing', function(){
|
|
describe('POST /uppercase', function(){
|
|
describe('with JSON', function(){
|
|
it('should work', function(done){
|
|
request
|
|
.post('/uppercase')
|
|
.send({ name: 'tobi' })
|
|
.expect(200)
|
|
.expect({ name: 'TOBI' }, done);
|
|
})
|
|
})
|
|
|
|
describe('with urlencoded', function(){
|
|
it('should work', function(done){
|
|
request
|
|
.post('/uppercase')
|
|
.send('name=tj')
|
|
.expect(200)
|
|
.expect({ name: 'TJ' }, done);
|
|
})
|
|
})
|
|
|
|
|
|
describe('when length > limit', function(){
|
|
it('should 413', function(done){
|
|
request
|
|
.post('/json')
|
|
.send({ name: Array(5000).join('a') })
|
|
.expect(413, done);
|
|
})
|
|
})
|
|
|
|
describe('when no name is sent', function(){
|
|
it('should 400', function(done){
|
|
request
|
|
.post('/uppsercase')
|
|
.send('age=10')
|
|
.expect(400, done);
|
|
});
|
|
});
|
|
})
|
|
}) |