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

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

71
 require('./test-blob')
71
 require('./test-blob')
72
 require('./test-firebase')
72
 require('./test-firebase')
73
 require('./test-android')
73
 require('./test-android')
74
+require('./benchmark')