Browse Source

Add test case

Ben Hsieh 8 years ago
parent
commit
212822bfa3
4 changed files with 38 additions and 2 deletions
  1. 0
    0
      src/ios/RNFetchBlobNetwork.h
  2. 0
    0
      src/ios/RNFetchBlobNetwork.m
  3. 36
    0
      test/test-0.5.x.js
  4. 2
    2
      test/test-init.js

src/ios/RNFetchBlobResp.h → src/ios/RNFetchBlobNetwork.h View File


src/ios/RNFetchBlobResp.m → src/ios/RNFetchBlobNetwork.m View File


+ 36
- 0
test/test-0.5.x.js View File

@@ -146,6 +146,42 @@ describe('Upload multipart data with file from storage', (report, done) => {
146 146
     })
147 147
 })
148 148
 
149
+describe('Upload and download at the same time', (report, done) => {
150
+
151
+  let content = 'POST and PUT calls with headers and body should also work correctly'
152
+  let filename = 'download-header-test-' + Date.now()
153
+  let body = RNFetchBlob.base64.encode(content)
154
+
155
+  RNFetchBlob
156
+    .config({
157
+      fileCache : true,
158
+    })
159
+    .fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
160
+      Authorization : `Bearer ${DROPBOX_TOKEN}`,
161
+      'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+filename+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
162
+      'Content-Type' : 'application/octet-stream',
163
+    }, body)
164
+    .then((resp) =>  {
165
+      return RNFetchBlob.fs.readStream(resp.path(), 'utf8')
166
+    })
167
+    .then((stream) => {
168
+      let actual = ''
169
+      stream.open()
170
+      stream.onData((chunk) => {
171
+        actual += chunk
172
+      })
173
+      stream.onEnd(() => {
174
+        report(
175
+          <Assert
176
+            key="response data should be the filename"
177
+            expect={filename}
178
+            actual={JSON.parse(actual).name} />)
179
+        done()
180
+      })
181
+    })
182
+
183
+})
184
+
149 185
 describe('Session create mechanism test', (report, done) => {
150 186
   let sessionName = 'foo-' + Date.now()
151 187
   testSessionName = sessionName

+ 2
- 2
test/test-init.js View File

@@ -51,7 +51,7 @@ describe('GET image from server', (report, done) => {
51 51
 })
52 52
 
53 53
 
54
-require('./test-fs')
55 54
 require('./test-0.1.x-0.4.x')
56 55
 require('./test-0.5.x')
57
-require('./test-android')
56
+// require('./test-fs')
57
+// require('./test-android')