@@ -4,6 +4,7 @@ var assert = require('assert');
44var fake = require ( 'fake' ) ;
55var mime = require ( 'mime-types' ) ;
66var http = require ( 'http' ) ;
7+ var IncomingForm = require ( 'formidable' ) . IncomingForm ;
78
89var common = module . exports ;
910
@@ -14,7 +15,9 @@ common.dir = {
1415 tmp : path . join ( rootDir , '/test/tmp' )
1516} ;
1617
17- common . defaultTypeValue = function ( ) { return new Buffer ( [ 1 , 2 , 3 ] ) ; } ;
18+ common . defaultTypeValue = function ( ) {
19+ return new Buffer ( [ 1 , 2 , 3 ] ) ;
20+ } ;
1821
1922common . assert = assert ;
2023common . fake = fake ;
@@ -28,13 +31,17 @@ common.httpsPort = 9443;
2831common . httpsServerKey = fs . readFileSync ( path . join ( __dirname , './fixture/key.pem' ) ) ;
2932common . httpsServerCert = fs . readFileSync ( path . join ( __dirname , './fixture/cert.pem' ) ) ;
3033
31- common . createServer = function ( form , FIELDS , callback ) {
34+ common . testFields = function ( FIELDS , callback ) {
35+
36+ var fieldsPassed = Object . keys ( FIELDS ) . length ;
37+
3238 return http . createServer ( function ( req , res ) {
3339
34- form . parse ( req ) ;
40+ var incomingForm = new IncomingForm ( { uploadDir : common . dir . tmp } ) ;
3541
36- var fieldsPassed = Object . keys ( FIELDS ) . length ;
37- common . actions . checkForm ( form , FIELDS , function ( fieldsChecked ) {
42+ incomingForm . parse ( req ) ;
43+
44+ common . actions . checkForm ( incomingForm , FIELDS , function ( fieldsChecked ) {
3845 // keep track of number of the processed fields
3946 callback ( fieldsPassed - fieldsChecked ) ;
4047 // finish it
0 commit comments