|
@@ -0,0 +1,57 @@
|
|
1
|
+import RNTest from './react-native-testkit/'
|
|
2
|
+import React from 'react'
|
|
3
|
+import RNFetchBlob from 'react-native-fetch-blob'
|
|
4
|
+
|
|
5
|
+import {
|
|
6
|
+ StyleSheet,
|
|
7
|
+ Text,
|
|
8
|
+ View,
|
|
9
|
+ ScrollView,
|
|
10
|
+ Platform,
|
|
11
|
+ Dimensions,
|
|
12
|
+ Image,
|
|
13
|
+} from 'react-native';
|
|
14
|
+
|
|
15
|
+const fs = RNFetchBlob.fs
|
|
16
|
+const { Assert, Comparer, Info, prop } = RNTest
|
|
17
|
+const describe = RNTest.config({
|
|
18
|
+ group : 'Android only functions',
|
|
19
|
+ run : true,
|
|
20
|
+ expand : false,
|
|
21
|
+})
|
|
22
|
+const { TEST_SERVER_URL, FILENAME, DROPBOX_TOKEN, styles } = prop()
|
|
23
|
+
|
|
24
|
+let prefix = ((Platform.OS === 'android') ? 'file://' : '')
|
|
25
|
+
|
|
26
|
+// Android only tests
|
|
27
|
+
|
|
28
|
+let tmpFilePath = null
|
|
29
|
+
|
|
30
|
+describe('Download with notification', (report, done) => {
|
|
31
|
+ let filePath = null
|
|
32
|
+ let filename = `test-${Date.now()}.png`
|
|
33
|
+ RNFetchBlob.fs.getSystemDirs().then((dirs) => {
|
|
34
|
+ filePath = `${dirs.DownloadDir}/${filename}`
|
|
35
|
+ return RNFetchBlob.config({
|
|
36
|
+ path : filePath,
|
|
37
|
+ addAndroidDownloads : {
|
|
38
|
+ title : 'RNFetchBlob test download success',
|
|
39
|
+ description : `File description added by RNFetchblob`,
|
|
40
|
+ mediaScannable : true,
|
|
41
|
+ mime : "image/png",
|
|
42
|
+ notification : true
|
|
43
|
+ }
|
|
44
|
+ })
|
|
45
|
+ .fetch('GET', `${TEST_SERVER_URL}/public/github2.jpg`)
|
|
46
|
+ })
|
|
47
|
+ .then((resp) => {
|
|
48
|
+ tmpFilePath = resp.path()
|
|
49
|
+ report(<Info key={`image from ${tmpFilePath}`}>
|
|
50
|
+ <Image
|
|
51
|
+ source={{ uri : prefix + tmpFilePath}}
|
|
52
|
+ style={styles.image}/>
|
|
53
|
+ </Info>)
|
|
54
|
+ done()
|
|
55
|
+ })
|
|
56
|
+
|
|
57
|
+})
|