File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments