瀏覽代碼

Add #74 test case

Ben Hsieh 8 年之前
父節點
當前提交
3a3a1fa62f
共有 1 個檔案被更改,包括 24 行新增0 行删除
  1. 24
    0
      test/test-android.js

+ 24
- 0
test/test-android.js 查看文件

@@ -126,3 +126,27 @@ describe('android download manager', (report, done) => {
126 126
     })
127 127
   })
128 128
 })
129
+
130
+// issue #74
131
+describe('download file to specific location using DownloadManager', (report, done) => {
132
+  let dest = dirs.DCIMDir + '/android-download-test-' +Date.now() + '.png'
133
+  RNFetchBlob.config({
134
+    addAndroidDownloads : {
135
+      useDownloadManager : true,
136
+      path : dest,
137
+      mime : 'image/png',
138
+      title : 'android-download-path-test.png',
139
+      description : 'download to specific path #74'
140
+    }
141
+  })
142
+  .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
143
+  .then((res) => fs.stat(res.path()))
144
+  .then((stat) => {
145
+    report(
146
+      <Assert key="file exists at the path"
147
+        expect={true} actual={true}/>,
148
+      <Assert key="file size correct"
149
+        expect="23975" actual={stat.size}/>)
150
+    done()
151
+  })
152
+})