@@ -112,7 +112,7 @@ describe('GET request test : path -> any', (report, done) => {
112112
113113} )
114114
115- describe ( 'POST base64 body auto strategy ' , ( report , done ) => {
115+ describe ( 'POST different types of body ' , ( report , done ) => {
116116
117117 let image = RNTest . prop ( 'image' )
118118 let tmpPath = dirs . DocumentDir + '/tmp-' + Date . now ( )
@@ -121,14 +121,12 @@ describe('POST base64 body auto strategy', (report, done) => {
121121 let name = `fetch-replacement-${ Platform . OS } -${ Date . now ( ) } .png`
122122 return pBody . then ( ( body ) =>
123123 fetch ( 'https://content.dropboxapi.com/2/files/upload' , {
124- method : method ,
124+ method : 'post' ,
125125 headers : {
126126 Authorization : `Bearer ${ DROPBOX_TOKEN } ` ,
127127 'Dropbox-API-Arg' : '{\"path\": \"/rn-upload/' + name + '\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}' ,
128128 'Content-Type' : 'application/octet-stream'
129- } ,
130- body : body
131- } )
129+ } , body } )
132130 )
133131 . then ( ( res ) => {
134132 return res . json ( )
@@ -139,12 +137,42 @@ describe('POST base64 body auto strategy', (report, done) => {
139137 }
140138
141139 let tests = [
142- upload ( 'upload base64 encoded body' , 'post' , Promise . resolve ( image ) ) ,
143- upload ( 'upload Blob body' , 'post' , Blob . build ( image , 'image/png;BASE64' ) ) ,
144- upload ( 'upload file path body' , 'post' , fs . writeFile ( tmpPath , image , 'base64' ) . then ( ( ) => Promise . resolve ( RNFetchBlob . wrap ( tmpPath ) ) ) )
140+ upload ( 'upload base64 encoded body' , Promise . resolve ( image ) ) ,
141+ upload ( 'upload Blob body' , Blob . build ( image , 'image/png;BASE64' ) ) ,
142+ upload ( 'upload file path body' , fs . writeFile ( tmpPath , image , 'base64' ) . then ( ( ) => Promise . resolve ( RNFetchBlob . wrap ( tmpPath ) ) ) )
145143 ]
146144
147145 Promise . all ( tests ) . then ( ( ) => done ( ) )
148146
147+ } )
148+
149+ describe ( 'check HTTP body correctness' , ( report , done ) => {
150+
151+ let tmpPath = dirs . DocumentDir + '/tmp-' + Date . now ( )
152+
153+ function upload ( pBody ) {
154+ return pBody . then ( ( body ) =>
155+ fetch ( 'https://content.dropboxapi.com/2/files/upload' , {
156+ method : 'POST' ,
157+ headers : {
158+ Authorization : `Bearer ${ DROPBOX_TOKEN } ` ,
159+ 'Dropbox-API-Arg' : '{\"path\": \"/rn-upload/' + name + '\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}' ,
160+ 'Content-Type' : 'application/octet-stream'
161+ } , body } )
162+ . then ( ( res ) => res . json ( ) )
163+ . then ( ( info ) => {
164+
165+ } )
166+ )
167+ }
168+
169+
170+ let pUnicodeBody = fetch ( `${ TEST_SERVER_URL } /public/utf8-dummy` , { method : 'GET' } )
171+ . then ( ( res ) => res . text ( ) )
172+
173+ let tests = [
174+ upload ( pUnicodeBody )
175+ ]
176+
149177
150178} )
0 commit comments