Browse Source

Correct test case

Ben Hsieh 8 years ago
parent
commit
9a94f72c84
2 changed files with 9 additions and 5 deletions
  1. 8
    5
      test/test-0.6.2.js
  2. 1
    0
      test/test-init.js

+ 8
- 5
test/test-0.6.2.js View File

@@ -28,27 +28,30 @@ let prefix = ((Platform.OS === 'android') ? 'file://' : '')
28 28
 let photo = null
29 29
 
30 30
 describe('upload asset from camera roll', (report, done) => {
31
-  let imgName = `image-from-camera-roll-${Platform.OS}.jpg`
31
+  let imgName = `image-from-camera-roll-${Platform.OS}-${Date.now()}.jpg`
32 32
   let tick = Date.now()
33
+  let tick2 = Date.now()
33 34
   CameraRoll.getPhotos({first : 10})
34 35
     .then((resp) => {
35
-      console.log('cameraroll', JSON.stringify(resp))
36 36
       let url = resp.edges[0].node.image.uri
37
+      console.log('CameraRoll',url)
37 38
       photo = url
38 39
       return RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
39 40
         Authorization : `Bearer ${DROPBOX_TOKEN}`,
40 41
         'Dropbox-API-Arg': `{\"path\": \"/rn-upload/${imgName}\",\"mode\": \"add\",\"autorename\": false,\"mute\": false}`,
41 42
         'Content-Type' : 'application/octet-stream',
42 43
       }, RNFetchBlob.wrap(url))
43
-      .progress((now, total) => {
44
-        if(Date.now() - tick < 1000)
44
+      .uploadProgress((now, total) => {
45
+        if(Date.now() - tick2 < 1000)
45 46
         return
46
-        report(<Info key="progress" uid="pg1">
47
+        report(<Info key="upload progress" uid="pg0">
47 48
           <Text>{`upload ${now} / ${total} ${Math.floor(now/total*100)}% `}</Text>
48 49
         </Info>)
50
+        tick2 = Date.now()
49 51
       })
50 52
     })
51 53
     .then((resp) => {
54
+      console.log(resp)
52 55
       resp = resp.json()
53 56
       report(
54 57
         <Assert key="confirm the file has been uploaded" expect={imgName} actual={resp.name}/>

+ 1
- 0
test/test-init.js View File

@@ -71,3 +71,4 @@ require('./test-xmlhttp')
71 71
 require('./test-blob')
72 72
 require('./test-firebase')
73 73
 require('./test-android')
74
+require('./benchmark')