Browse Source

Add test files and test case

Ben Hsieh 8 years ago
parent
commit
f46ecf8012
4 changed files with 19 additions and 2 deletions
  1. 2
    0
      test-server/.gitignore
  2. BIN
      test-server/public/beethoven.mp3
  3. BIN
      test-server/public/cat-fu.mp4
  4. 17
    2
      test/test-android.js

+ 2
- 0
test-server/.gitignore View File

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

BIN
test-server/public/beethoven.mp3 View File


BIN
test-server/public/cat-fu.mp4 View File


+ 17
- 2
test/test-android.js View File

@@ -59,7 +59,9 @@ describe('Download with notification', (report, done) => {
59 59
 describe('MediaScanner tests ', (report, done) => {
60 60
   let filePath = null
61 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 65
     filePath = `${dirs.DownloadDir}/${filename}`
64 66
     return RNFetchBlob.config({
65 67
         path : filePath,
@@ -68,11 +70,24 @@ describe('MediaScanner tests ', (report, done) => {
68 70
   })
69 71
   .then((resp) => {
70 72
     tmpFilePath = resp.path()
71
-    RNFetchBlob.fs.scanFile([
73
+    return RNFetchBlob.fs.scanFile([
72 74
       { path:resp.path() }
73 75
     ])
74 76
     .then(() => {
75 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 91
       done()
77 92
     })
78 93
   })