Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 3c15f55

Browse files
committed
Add 0.9.2 test case
1 parent 2423ef1 commit 3c15f55

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

test-server/server.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ app.all('/xhr-code/:code', (req, res) => {
136136
res.status(Math.floor(req.params.code)).send()
137137
})
138138

139+
app.all('/content-length', (req, res) => {
140+
console.log(req.headers)
141+
res.send(req.headers['Content-Length'])
142+
})
143+
139144
app.all('/xhr-header', (req, res) => {
140145
console.log(req.headers)
141146
// res.header('Content-Type', 'application/json')

test/test-0.9.2.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
})

0 commit comments

Comments
 (0)