|
@@ -0,0 +1,47 @@
|
|
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
|
+window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
|
|
16
|
+window.Blob = RNFetchBlob.polyfill.Blob
|
|
17
|
+window.fetch = new RNFetchBlob.polyfill.Fetch({
|
|
18
|
+ auto : true,
|
|
19
|
+ binaryContentTypes : ['image/', 'video/', 'audio/']
|
|
20
|
+}).build()
|
|
21
|
+
|
|
22
|
+const fs = RNFetchBlob.fs
|
|
23
|
+const { Assert, Comparer, Info, prop } = RNTest
|
|
24
|
+const describe = RNTest.config({
|
|
25
|
+ group : '0.9.2',
|
|
26
|
+ run : true,
|
|
27
|
+ expand : true,
|
|
28
|
+ timeout : 20000,
|
|
29
|
+})
|
|
30
|
+const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
|
|
31
|
+const dirs = RNFetchBlob.fs.dirs
|
|
32
|
+
|
|
33
|
+let prefix = ((Platform.OS === 'android') ? 'file://' : '')
|
|
34
|
+
|
|
35
|
+describe('content-length header test', (report, done) => {
|
|
36
|
+ RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/content-length`, {
|
|
37
|
+ 'Content-Type' : 'text/plain',
|
|
38
|
+ 'Content-Length' : '5'
|
|
39
|
+ }, 'hello')
|
|
40
|
+ .then((res) => {
|
|
41
|
+ report(
|
|
42
|
+ <Info key="response data">
|
|
43
|
+ <Text>{res.text()}</Text>
|
|
44
|
+ </Info>)
|
|
45
|
+ done()
|
|
46
|
+ })
|
|
47
|
+})
|