瀏覽代碼

Add test case for #47 #45

Ben Hsieh 8 年之前
父節點
當前提交
54c5584d1d
共有 1 個檔案被更改,包括 17 行新增15 行删除
  1. 17
    15
      test/test-0.5.1.js

+ 17
- 15
test/test-0.5.1.js 查看文件

@@ -213,25 +213,27 @@ RNTest.config({
213 213
   })
214 214
   .then((res) => {
215 215
     deb = Date.now()
216
-    return RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
216
+    let promise =  RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
217 217
       Authorization : `Bearer ${DROPBOX_TOKEN}`,
218 218
       'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+filename+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
219 219
       'Content-Type' : 'application/octet-stream',
220 220
     }, RNFetchBlob.wrap(res.path()))
221
-    .progress((now, total) => {
222
-      if(Date.now() - deb < 1000)
223
-        return
224
-      deb = Date.now()
225
-      if(begin2 === -1)
226
-        begin2 = Date.now()
227
-      let speed = Math.floor(now / (Date.now() - begin2))
228
-      report(<Info uid="100"  key="progress">
229
-        <Text>
230
-          {`upload ${now} / ${total} bytes (${speed} kb/s)`}
231
-          {` ${Math.floor((total-now)/speed/1000)} seconds left`}
232
-        </Text>
233
-      </Info>)
234
-    })
221
+    if(Platform.OS === 'ios')
222
+      promise.progress((now, total) => {
223
+        if(Date.now() - deb < 1000)
224
+          return
225
+        deb = Date.now()
226
+        if(begin2 === -1)
227
+          begin2 = Date.now()
228
+        let speed = Math.floor(now / (Date.now() - begin2))
229
+        report(<Info uid="100"  key="progress">
230
+          <Text>
231
+            {`upload ${now} / ${total} bytes (${speed} kb/s)`}
232
+            {` ${Math.floor((total-now)/speed/1000)} seconds left`}
233
+          </Text>
234
+        </Info>)
235
+      })
236
+    return promise
235 237
   })
236 238
   .then((res) => {
237 239
     report(<Assert