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

Commit 32a265a

Browse files
committed
#8 Add test cases for large file and memory leaking
1 parent 710d60d commit 32a265a

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

test/test-0.5.x.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,33 @@ describe('Upload and download at the same time', (report, done) => {
182182

183183
})
184184

185+
RNTest.config({
186+
group : '0.5.x',
187+
run : true,
188+
expand : false,
189+
timeout : 30000,
190+
})('Upload and download large file', (report, done) => {
191+
let filename = '22mb-dummy-' + Date.now()
192+
RNFetchBlob.config({
193+
fileCache : true
194+
})
195+
.fetch('GET', `${TEST_SERVER_URL}/public/22mb-dummy`)
196+
.then((res) => {
197+
return RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
198+
Authorization : `Bearer ${DROPBOX_TOKEN}`,
199+
'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+filename+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
200+
'Content-Type' : 'application/octet-stream',
201+
}, RNFetchBlob.wrap(res.path()))
202+
})
203+
.then((res) => {
204+
report(<Assert
205+
key="upload should success withou crashing app"
206+
expect={filename}
207+
actual={res.json().name}/>)
208+
done()
209+
})
210+
})
211+
185212
describe('Session create mechanism test', (report, done) => {
186213
let sessionName = 'foo-' + Date.now()
187214
testSessionName = sessionName

test/test-init.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,26 @@ describe('GET image from server', (report, done) => {
5050
})
5151
})
5252

53+
// // Only use when doing memory leaking test
54+
// RNTest.config({
55+
// timeout : 900000000
56+
// })('Memory leaking test', (report, done) => {
57+
// let promises = []
58+
// for(let i = 0 ; i < 2000; i++) {
59+
// promises.push(RNFetchBlob
60+
// .fetch('GET', `${TEST_SERVER_URL}/public/github.png`, {
61+
// Authorization : 'Bearer abde123eqweje'
62+
// })
63+
// )
64+
// }
65+
// Promise.all(promises).then(() => {
66+
// report(<Assert key="test finished" expect={true} actual={true}/>)
67+
// done()
68+
// })
69+
// })
70+
5371

5472
require('./test-0.1.x-0.4.x')
5573
require('./test-0.5.x')
56-
// require('./test-fs')
57-
// require('./test-android')
74+
require('./test-fs')
75+
require('./test-android')

0 commit comments

Comments
 (0)