浏览代码

Add test files and test case

Ben Hsieh 9 年前
父节点
当前提交
f46ecf8012
共有 4 个文件被更改,包括 19 次插入2 次删除
  1. 2
    0
      test-server/.gitignore
  2. 二进制
      test-server/public/beethoven.mp3
  3. 二进制
      test-server/public/cat-fu.mp4
  4. 17
    2
      test/test-android.js

+ 2
- 0
test-server/.gitignore 查看文件

4
 !public/github2.jpg
4
 !public/github2.jpg
5
 !public/22mb-dummy
5
 !public/22mb-dummy
6
 !public/1mb-dummy
6
 !public/1mb-dummy
7
+!public/beethoven.mp3
8
+!public/cat-fu.mp4
7
 !uploads/readme
9
 !uploads/readme

二进制
test-server/public/beethoven.mp3 查看文件


二进制
test-server/public/cat-fu.mp4 查看文件


+ 17
- 2
test/test-android.js 查看文件

59
 describe('MediaScanner tests ', (report, done) => {
59
 describe('MediaScanner tests ', (report, done) => {
60
   let filePath = null
60
   let filePath = null
61
   let filename = `scannable-test-${Date.now()}.png`
61
   let filename = `scannable-test-${Date.now()}.png`
62
-  RNFetchBlob.fs.getSystemDirs().then((dirs) => {
62
+  let dirs = null
63
+  RNFetchBlob.fs.getSystemDirs().then((resp) => {
64
+    dirs = resp
63
     filePath = `${dirs.DownloadDir}/${filename}`
65
     filePath = `${dirs.DownloadDir}/${filename}`
64
     return RNFetchBlob.config({
66
     return RNFetchBlob.config({
65
         path : filePath,
67
         path : filePath,
68
   })
70
   })
69
   .then((resp) => {
71
   .then((resp) => {
70
     tmpFilePath = resp.path()
72
     tmpFilePath = resp.path()
71
-    RNFetchBlob.fs.scanFile([
73
+    return RNFetchBlob.fs.scanFile([
72
       { path:resp.path() }
74
       { path:resp.path() }
73
     ])
75
     ])
74
     .then(() => {
76
     .then(() => {
75
       report(<Assert key="scan success" expect={true} actual={true}/>)
77
       report(<Assert key="scan success" expect={true} actual={true}/>)
78
+      return RNFetchBlob
79
+              .config({
80
+                path : dirs.DCIMDir + '/beethoven-'+ Date.now() +'.mp3'
81
+              })
82
+              .fetch('GET', `${TEST_SERVER_URL}/public/beethoven.mp3`)
83
+    })
84
+  })
85
+  .then((resp) => {
86
+    fs.scanFile([{
87
+      path : resp.path()
88
+    }])
89
+    .then(() => {
90
+      report(<Assert key="scan mp3 file success" expect={true} actual={true}/>)
76
       done()
91
       done()
77
     })
92
     })
78
   })
93
   })