@@ -10,111 +10,111 @@ var should = require('should');
1010describe ( 'multipart()' , function ( ) {
1111 it ( 'should ignore GET' , function ( done ) {
1212 request ( createServer ( ) )
13- . get ( '/body' )
14- . field ( 'user' , 'Tobi' )
15- . expect ( 200 , { } , done )
13+ . get ( '/body' )
14+ . field ( 'user' , 'Tobi' )
15+ . expect ( 200 , { } , done )
1616 } )
1717
1818 describe ( 'with multipart/form-data' , function ( ) {
1919 it ( 'should populate req.body' , function ( done ) {
2020 request ( createServer ( ) )
21- . post ( '/body' )
22- . field ( 'user' , 'Tobi' )
23- . expect ( 200 , { user : 'Tobi' } , done )
21+ . post ( '/body' )
22+ . field ( 'user' , 'Tobi' )
23+ . expect ( 200 , { user : 'Tobi' } , done )
2424 } )
2525
2626 it ( 'should handle duplicated middleware' , function ( done ) {
2727 var app = connect ( )
28- . use ( multipart ( ) )
29- . use ( multipart ( ) )
30- . use ( function ( req , res ) {
31- res . setHeader ( 'Content-Type' , 'application/json; charset=utf-8' )
32- res . end ( JSON . stringify ( req . body ) )
33- } )
28+ . use ( multipart ( ) )
29+ . use ( multipart ( ) )
30+ . use ( function ( req , res ) {
31+ res . setHeader ( 'Content-Type' , 'application/json; charset=utf-8' )
32+ res . end ( JSON . stringify ( req . body ) )
33+ } )
3434
3535 request ( app )
36- . post ( '/body' )
37- . field ( 'user' , 'Tobi' )
38- . expect ( 200 , { user : 'Tobi' } , done )
36+ . post ( '/body' )
37+ . field ( 'user' , 'Tobi' )
38+ . expect ( 200 , { user : 'Tobi' } , done )
3939 } )
4040
4141 it ( 'should support files' , function ( done ) {
4242 request ( createServer ( ) )
43- . post ( '/files' )
44- . attach ( 'text' , Buffer . from ( 'some text here' ) , 'foo.txt' )
45- . expect ( 200 )
46- . expect ( shouldDeepIncludeInBody ( {
47- text : {
48- name : 'foo.txt' ,
49- originalFilename : 'foo.txt' ,
50- size : 14 ,
51- type : 'text/plain'
52- }
53- } ) )
54- . end ( done )
43+ . post ( '/files' )
44+ . attach ( 'text' , Buffer . from ( 'some text here' ) , 'foo.txt' )
45+ . expect ( 200 )
46+ . expect ( shouldDeepIncludeInBody ( {
47+ text : {
48+ name : 'foo.txt' ,
49+ originalFilename : 'foo.txt' ,
50+ size : 14 ,
51+ type : 'text/plain'
52+ }
53+ } ) )
54+ . end ( done )
5555 } )
5656
5757 it ( 'should work with multiple fields' , function ( done ) {
5858 request ( createServer ( ) )
59- . post ( '/body' )
60- . field ( 'user' , 'Tobi' )
61- . field ( 'age' , '1' )
62- . expect ( 200 , { user : 'Tobi' , age : '1' } , done )
59+ . post ( '/body' )
60+ . field ( 'user' , 'Tobi' )
61+ . field ( 'age' , '1' )
62+ . expect ( 200 , { user : 'Tobi' , age : '1' } , done )
6363 } )
6464
6565 it ( 'should handle duplicated fields' , function ( done ) {
6666 request ( createServer ( ) )
67- . post ( '/body' )
68- . field ( 'user' , 'Tobi' )
69- . field ( 'user' , 'Loki' )
70- . field ( 'user' , 'Poki' )
71- . expect ( 200 , { user : [ 'Tobi' , 'Loki' , 'Poki' ] } , done )
67+ . post ( '/body' )
68+ . field ( 'user' , 'Tobi' )
69+ . field ( 'user' , 'Loki' )
70+ . field ( 'user' , 'Poki' )
71+ . expect ( 200 , { user : [ 'Tobi' , 'Loki' , 'Poki' ] } , done )
7272 } )
7373
7474 it ( 'should support nesting' , function ( done ) {
7575 request ( createServer ( ) )
76- . post ( '/body' )
77- . field ( 'user[name][first]' , 'tobi' )
78- . field ( 'user[name][last]' , 'holowaychuk' )
79- . field ( 'user[age]' , '1' )
80- . field ( 'species' , 'ferret' )
81- . expect ( 200 , {
82- species : 'ferret' ,
83- user : {
84- age : '1' ,
85- name : { first : 'tobi' , last : 'holowaychuk' }
86- }
87- } , done )
76+ . post ( '/body' )
77+ . field ( 'user[name][first]' , 'tobi' )
78+ . field ( 'user[name][last]' , 'holowaychuk' )
79+ . field ( 'user[age]' , '1' )
80+ . field ( 'species' , 'ferret' )
81+ . expect ( 200 , {
82+ species : 'ferret' ,
83+ user : {
84+ age : '1' ,
85+ name : { first : 'tobi' , last : 'holowaychuk' }
86+ }
87+ } , done )
8888 } )
8989
9090 it ( 'should support multiple files of the same name' , function ( done ) {
9191 request ( createServer ( ) )
92- . post ( '/files' )
93- . attach ( 'text' , Buffer . from ( 'some text here' ) , 'foo.txt' )
94- . attach ( 'text' , Buffer . from ( 'some more text stuff' ) , 'bar.txt' )
95- . expect ( 200 )
96- . expect ( shouldDeepIncludeInBody ( {
97- text : [
98- { name : 'foo.txt' } ,
99- { name : 'bar.txt' }
100- ]
101- } ) )
102- . end ( done )
92+ . post ( '/files' )
93+ . attach ( 'text' , Buffer . from ( 'some text here' ) , 'foo.txt' )
94+ . attach ( 'text' , Buffer . from ( 'some more text stuff' ) , 'bar.txt' )
95+ . expect ( 200 )
96+ . expect ( shouldDeepIncludeInBody ( {
97+ text : [
98+ { name : 'foo.txt' } ,
99+ { name : 'bar.txt' }
100+ ]
101+ } ) )
102+ . end ( done )
103103 } )
104104
105105 it ( 'should support nested files' , function ( done ) {
106106 request ( createServer ( ) )
107- . post ( '/files' )
108- . attach ( 'docs[foo]' , Buffer . from ( 'some text here' ) , 'foo.txt' )
109- . attach ( 'docs[bar]' , Buffer . from ( 'some more text stuff' ) , 'bar.txt' )
110- . expect ( 200 )
111- . expect ( shouldDeepIncludeInBody ( {
112- docs : {
113- foo : { name : 'foo.txt' } ,
114- bar : { name : 'bar.txt' }
115- }
116- } ) )
117- . end ( done )
107+ . post ( '/files' )
108+ . attach ( 'docs[foo]' , Buffer . from ( 'some text here' ) , 'foo.txt' )
109+ . attach ( 'docs[bar]' , Buffer . from ( 'some more text stuff' ) , 'bar.txt' )
110+ . expect ( 200 )
111+ . expect ( shouldDeepIncludeInBody ( {
112+ docs : {
113+ foo : { name : 'foo.txt' } ,
114+ bar : { name : 'bar.txt' }
115+ }
116+ } ) )
117+ . end ( done )
118118 } )
119119
120120 it ( 'should next(err) on multipart failure' , function ( done ) {
@@ -155,18 +155,18 @@ describe('multipart()', function(){
155155
156156 it ( 'should default req.files to {}' , function ( done ) {
157157 request ( createServer ( ) )
158- . post ( '/body' )
159- . expect ( 200 , { } , done )
158+ . post ( '/body' )
159+ . expect ( 200 , { } , done )
160160 } )
161161
162162 it ( 'should return 413 on maxFilesSize exceeded' , function ( done ) {
163163 var max = Math . pow ( 2 , 9 )
164164
165165 request ( createServer ( { maxFilesSize : max } ) )
166- . post ( '/files' )
167- . field ( 'user[name]' , 'Tobi' )
168- . attach ( 'text' , Buffer . alloc ( max + 1 , 'x' ) , 'foo.txt' )
169- . expect ( 413 , done )
166+ . post ( '/files' )
167+ . field ( 'user[name]' , 'Tobi' )
168+ . attach ( 'text' , Buffer . alloc ( max + 1 , 'x' ) , 'foo.txt' )
169+ . expect ( 413 , done )
170170 } )
171171 } )
172172} )
0 commit comments