Browse Source

Add 0.9.2 test case

Ben Hsieh 8 years ago
parent
commit
3c15f55c34
2 changed files with 52 additions and 0 deletions
  1. 5
    0
      test-server/server.js
  2. 47
    0
      test/test-0.9.2.js

+ 5
- 0
test-server/server.js View File

@@ -136,6 +136,11 @@ app.all('/xhr-code/:code', (req, res) => {
136 136
   res.status(Math.floor(req.params.code)).send()
137 137
 })
138 138
 
139
+app.all('/content-length', (req, res) => {
140
+  console.log(req.headers)
141
+  res.send(req.headers['Content-Length'])
142
+})
143
+
139 144
 app.all('/xhr-header', (req, res) => {
140 145
   console.log(req.headers)
141 146
   // res.header('Content-Type', 'application/json')

+ 47
- 0
test/test-0.9.2.js View File

@@ -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
+})