|
@@ -0,0 +1,66 @@
|
|
1
|
+import RNTest from './react-native-testkit/'
|
|
2
|
+import React from 'react'
|
|
3
|
+import RNFetchBlob from 'react-native-fetch-blob'
|
|
4
|
+import {
|
|
5
|
+ StyleSheet,
|
|
6
|
+ Text,
|
|
7
|
+ View,
|
|
8
|
+ ScrollView,
|
|
9
|
+ Platform,
|
|
10
|
+ Dimensions,
|
|
11
|
+ Image,
|
|
12
|
+} from 'react-native';
|
|
13
|
+
|
|
14
|
+window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
|
|
15
|
+window.Blob = RNFetchBlob.polyfill.Blob
|
|
16
|
+// window.fetch = new RNFetchBlob.polyfill.Fetch({
|
|
17
|
+// auto : true,
|
|
18
|
+// binaryContentTypes : ['image/', 'video/', 'audio/']
|
|
19
|
+// }).build()
|
|
20
|
+
|
|
21
|
+const fs = RNFetchBlob.fs
|
|
22
|
+const { Assert, Comparer, Info, prop } = RNTest
|
|
23
|
+const describe = RNTest.config({
|
|
24
|
+ group : '0.9.4',
|
|
25
|
+ run : true,
|
|
26
|
+ expand : true,
|
|
27
|
+ timeout : 20000,
|
|
28
|
+})
|
|
29
|
+const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
|
|
30
|
+const dirs = RNFetchBlob.fs.dirs
|
|
31
|
+
|
|
32
|
+let prefix = ((Platform.OS === 'android') ? 'file://' : '')
|
|
33
|
+
|
|
34
|
+describe('issue #105', (report, done) => {
|
|
35
|
+ let tmp = null
|
|
36
|
+ RNFetchBlob
|
|
37
|
+ .config({ fileCache : true })
|
|
38
|
+ .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
|
|
39
|
+ .then((res) => {
|
|
40
|
+ tmp = res.path()
|
|
41
|
+ return RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
|
|
42
|
+ 'Content-Type' : 'multipart/form-data'
|
|
43
|
+ }, [
|
|
44
|
+ { name : 'data', data : 'issue#105 test' },
|
|
45
|
+ { name : 'file', filename : 'github.png', data : RNFetchBlob.wrap(tmp) }
|
|
46
|
+ ])
|
|
47
|
+ })
|
|
48
|
+ .then((res) => {
|
|
49
|
+ done()
|
|
50
|
+ })
|
|
51
|
+})
|
|
52
|
+
|
|
53
|
+describe('issue #106', (report, done) => {
|
|
54
|
+
|
|
55
|
+ fetch('https://rnfb-test-app.firebaseapp.com/6m-json.json')
|
|
56
|
+ .then((res) => {
|
|
57
|
+ console.log('##',res)
|
|
58
|
+ console.log('## converted')
|
|
59
|
+ return res.json()
|
|
60
|
+ })
|
|
61
|
+ .then((data) => {
|
|
62
|
+ console.log(data)
|
|
63
|
+ done()
|
|
64
|
+ })
|
|
65
|
+
|
|
66
|
+})
|