Skip to content

Commit 7ff6c14

Browse files
committed
no body test case
1 parent dd989e2 commit 7ff6c14

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/test_nobody.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
var koa = require('koa'),
4+
request = require('supertest');
5+
require('should');
6+
7+
8+
function create_app(){
9+
var app = koa();
10+
// app.use(require('koa-body')({multipart:true , formidable:{keepExtensions:true}}));
11+
app.use(require('../lib/validate.js')());
12+
app.use(require('koa-router')(app));
13+
return app;
14+
}
15+
16+
describe('koa-validate' , function(){
17+
it("nobody to check" , function(done){
18+
var app = create_app();
19+
app.post('/nobody',function*(){
20+
this.checkBody('body').notEmpty();
21+
if(this.errors) {
22+
this.status=500;
23+
}else{
24+
this.status=200;
25+
}
26+
});
27+
var req = request(app.listen());
28+
req.post('/nobody')
29+
.send({body:"no"})
30+
.expect(500 , done);
31+
});
32+
33+
});

0 commit comments

Comments
 (0)