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

Commit c37ba9a

Browse files
committed
Add test case #115
1 parent e1cb0e2 commit c37ba9a

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

test-server/server.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,20 @@ app.all('/timeout408/:time', (req, res) => {
166166
}, 5000)
167167
})
168168

169-
app.all('/long', (req, res) => {
169+
app.all('/long/:ticks', (req, res) => {
170+
var count = 0;
171+
var it = setInterval(() => {
172+
console.log('write data', count)
173+
res.write('a')
174+
if(++count > req.params.ticks){
175+
clearInterval(it)
176+
res.end()
177+
}
178+
}, 1000);
179+
180+
})
181+
182+
app.all('/long/', (req, res) => {
170183
var count = 0;
171184
var it = setInterval(() => {
172185
console.log('write data', count)

test/test-background.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
Linking,
10+
Platform,
11+
Dimensions,
12+
AsyncStorage,
13+
Image,
14+
} from 'react-native';
15+
const JSONStream = RNFetchBlob.JSONStream
16+
const fs = RNFetchBlob.fs
17+
const { Assert, Comparer, Info, prop } = RNTest
18+
const describe = RNTest.config({
19+
group : 'background',
20+
run : true,
21+
expand : true,
22+
timeout : 20000,
23+
})
24+
const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
25+
const dirs = RNFetchBlob.fs.dirs
26+
let prefix = ((Platform.OS === 'android') ? 'file://' : '')
27+
let begin = Date.now()
28+
29+
describe('background http response', (report, done) => {
30+
let count = 0
31+
32+
let task = RNFetchBlob.config({
33+
timeout : -1
34+
}).fetch('GET', `${TEST_SERVER_URL}/long/3600`, {
35+
'Cache-Control' : 'no-store'
36+
})
37+
38+
task.expire(() => {
39+
done()
40+
})
41+
42+
task.catch((err) => {
43+
console.log(err)
44+
})
45+
46+
task.then((res) => {
47+
console.log('resp response received', res.data.length)
48+
// done()
49+
})
50+
51+
})

0 commit comments

Comments
 (0)