Browse Source

Add test cases for 0.6.0

Ben Hsieh 8 years ago
parent
commit
1bc677b9d0
2 changed files with 28 additions and 8 deletions
  1. 23
    3
      test/test-android.js
  2. 5
    5
      test/test-init.js

+ 23
- 3
test/test-android.js View File

@@ -96,12 +96,32 @@ describe('android download manager', (report, done) => {
96 96
   RNFetchBlob.config({
97 97
     addAndroidDownloads : {
98 98
       useDownloadManager : true,
99
-      title : 'RNFetchBlob test download success',
99
+      title : 'RNFetchBlob test download manager test',
100 100
       description : `File description added by RNFetchblob`,
101 101
       mediaScannable : true,
102
-      mime : "image/png",
103 102
       notification : true
104 103
     }
105 104
   })
106
-  .fetch('GET', `${TEST_SERVER_URL}/public/beethoven.mp3`)
105
+  .fetch('GET', `${TEST_SERVER_URL}/public/beethoven.mp3`).then((resp) => {
106
+    report(
107
+      <Assert key="download manager complete handler" expect={true} actual={true}/>
108
+    )
109
+    return resp.readStream('ascii')
110
+  })
111
+  .then((stream) => {
112
+    stream.open();
113
+    let len = 0
114
+    stream.onData((chunk) => {
115
+      len += chunk.length
116
+    })
117
+    stream.onEnd(() => {
118
+      report(
119
+        <Assert key="download manager URI is readable"
120
+          expect={len}
121
+          comparer={Comparer.greater}
122
+          actual={0}/>
123
+      )
124
+      done()
125
+    })
126
+  })
107 127
 })

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

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