Browse Source

Added test case for #48

Ben Hsieh 8 years ago
parent
commit
381f2f7133
2 changed files with 76 additions and 7 deletions
  1. 68
    0
      test/test-0.6.3.js
  2. 8
    7
      test/test-init.js

+ 68
- 0
test/test-0.6.3.js View File

@@ -0,0 +1,68 @@
1
+import RNTest from './react-native-testkit/'
2
+import React from 'react'
3
+import RNFetchBlob from 'react-native-fetch-blob'
4
+import Timer from 'react-timer-mixin'
5
+
6
+import {
7
+  StyleSheet,
8
+  Text,
9
+  View,
10
+  ScrollView,
11
+  CameraRoll,
12
+  Platform,
13
+  Dimensions,
14
+  Image,
15
+} from 'react-native';
16
+
17
+const fs = RNFetchBlob.fs
18
+const { Assert, Comparer, Info, prop } = RNTest
19
+const describe = RNTest.config({
20
+  group : '0.6.3',
21
+  run : true,
22
+  expand : true,
23
+  timeout : 300000000,
24
+})
25
+const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, DROPBOX_TOKEN, styles } = prop()
26
+const  dirs = RNFetchBlob.fs.dirs
27
+
28
+let prefix = ((Platform.OS === 'android') ? 'file://' : '')
29
+
30
+describe('upload asset from camera roll', (report, done) => {
31
+  try {
32
+  let promises = []
33
+  let progress = []
34
+  let begin = Date.now()
35
+  for(let i=0; i<1500;i++) {
36
+    let p = RNFetchBlob
37
+    .config({fileCache : true})
38
+    .fetch('GET', `${TEST_SERVER_URL}/public/github2.png`)
39
+    // .progress(function(current, total){
40
+    //   progress[this] = current/total
41
+    // }.bind(i))
42
+    promises.push(p)
43
+  }
44
+  // let it = Timer.setInterval(() => {
45
+  //   function pgs() {
46
+  //     let res = []
47
+  //     for(var i in progress) {
48
+  //       res.push(<Text key={`download#${i}`}>{`download #${i} ${Math.floor(progress[i]*100)}%`}</Text>)
49
+  //     }
50
+  //     return res
51
+  //   }
52
+  //   report(<Info key={`progress monitor`} uid="progress">
53
+  //     {pgs()}
54
+  //   </Info>)
55
+  // }, 1000)
56
+  Promise.all(promises).then((resps) => {
57
+    for(let i in resps) {
58
+      fs.unlink(resps[i].path())
59
+    }
60
+    report(<Info key={`time = ${(Date.now() - begin) / 1000} sec`}></Info>)
61
+    // Timer.clearInterval(it)
62
+    done()
63
+  })
64
+} catch(err) {
65
+  console.log(err)
66
+}
67
+
68
+})

+ 8
- 7
test/test-init.js View File

@@ -52,10 +52,11 @@ describe('GET image from server', (report, done) => {
52 52
 })
53 53
 
54 54
 
55
-require('./test-0.1.x-0.4.x')
56
-require('./test-0.5.1')
57
-require('./test-0.5.2')
58
-require('./test-0.6.0')
59
-require('./test-0.6.2')
60
-require('./test-fs')
61
-require('./test-android')
55
+// require('./test-0.1.x-0.4.x')
56
+// require('./test-0.5.1')
57
+// require('./test-0.5.2')
58
+// require('./test-0.6.0')
59
+// require('./test-0.6.2')
60
+require('./test-0.6.3')
61
+// require('./test-fs')
62
+// require('./test-android')