@@ -14,20 +14,21 @@ var FIELDS = {
1414 } ,
1515 'custom_type' : {
1616 value : 'my_value' ,
17- type : 'image/png' ,
17+ expectedType : 'image/png' ,
1818 options : {
1919 contentType : 'image/png'
2020 }
2121 } ,
2222 'default_type' : {
23- type : FormData . DEFAULT_CONTENT_TYPE ,
23+ expectedType : FormData . DEFAULT_CONTENT_TYPE ,
2424 value : function ( ) { return new Buffer ( [ 1 , 2 , 3 ] ) ; }
2525 } ,
2626 'implicit_type' : {
27- type : mime . lookup ( common . dir . fixture + '/unicycle.jpg' ) ,
27+ expectedType : mime . lookup ( common . dir . fixture + '/unicycle.jpg' ) ,
2828 value : function ( ) { return fs . createReadStream ( common . dir . fixture + '/unicycle.jpg' ) ; }
2929 }
3030} ;
31+ var fieldsPassed = false ;
3132
3233var server = http . createServer ( function ( req , res ) {
3334 var body = '' ;
@@ -44,15 +45,17 @@ var server = http.createServer(function(req, res) {
4445 assert . ok ( fields [ 0 ] . indexOf ( 'Content-Type"' ) === - 1 ) ;
4546
4647 assert . ok ( fields [ 1 ] . indexOf ( 'name="custom_type"' ) > - 1 ) ;
47- assert . ok ( fields [ 1 ] . indexOf ( 'Content-Type: ' + FIELDS . custom_type . type ) > - 1 ) ;
48+ assert . ok ( fields [ 1 ] . indexOf ( 'Content-Type: ' + FIELDS . custom_type . expectedType ) > - 1 ) ;
4849
4950 assert . ok ( fields [ 2 ] . indexOf ( 'name="default_type"' ) > - 1 ) ;
50- assert . ok ( fields [ 2 ] . indexOf ( 'Content-Type: ' + FIELDS . default_type . type ) > - 1 ) ;
51+ assert . ok ( fields [ 2 ] . indexOf ( 'Content-Type: ' + FIELDS . default_type . expectedType ) > - 1 ) ;
5152
5253 assert . ok ( fields [ 3 ] . indexOf ( 'name="implicit_type"' ) > - 1 ) ;
53- assert . ok ( fields [ 3 ] . indexOf ( 'Content-Type: ' + FIELDS . implicit_type . type ) > - 1 ) ;
54+ assert . ok ( fields [ 3 ] . indexOf ( 'Content-Type: ' + FIELDS . implicit_type . expectedType ) > - 1 ) ;
55+
56+ fieldsPassed = true ;
57+ res . end ( ) ;
5458 } ) ;
55- res . end ( ) ;
5659
5760} ) ;
5861
@@ -88,4 +91,8 @@ server.listen(common.port, function() {
8891 server . close ( ) ;
8992 } ) ;
9093
94+ } ) ;
95+
96+ process . on ( 'exit' , function ( ) {
97+ assert . ok ( fieldsPassed ) ;
9198} ) ;
0 commit comments