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

Commit 20b2c3c

Browse files
committed
Fix 0.7.0 test case
1 parent 0fb6635 commit 20b2c3c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

test/test-0.7.0.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ describe('Upload and download large file', (report, done) => {
3333
let begin = -1
3434
let begin2 = -1
3535
let deb = Date.now()
36+
let download = false, upload = false
3637
RNFetchBlob.config({
3738
fileCache : true
3839
})
39-
.fetch('GET', `${TEST_SERVER_URL}/public/1mb-dummy`)
40+
.fetch('GET', `${TEST_SERVER_URL}/public/2mb-dummy`)
4041
.progress((now, total) => {
42+
download = true
4143
if(begin === -1)
4244
begin = Date.now()
4345
if(Date.now() - deb < 1000)
@@ -57,6 +59,29 @@ describe('Upload and download large file', (report, done) => {
5759
report(<Info key="big file stat">
5860
<Text>{JSON.stringify(stat)}</Text>
5961
</Info>)
62+
let task = RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
63+
Authorization : `Bearer ${DROPBOX_TOKEN}`,
64+
'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+filename+Date.now()+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
65+
'Content-Type' : 'application/octet-stream',
66+
}, RNFetchBlob.wrap(bigfile))
67+
begin = -1
68+
task.uploadProgress((now, total) => {
69+
upload = true
70+
if(begin === -1)
71+
begin = Date.now()
72+
if(Date.now() - deb < 1000)
73+
return
74+
deb = Date.now()
75+
report(<Info uid="300" key="upload progress">
76+
<Text>
77+
{`upload ${now} / ${total} bytes (${Math.floor(now / (Date.now() - begin))} kb/s) ${(100*now/total).toFixed(2)}%`}
78+
</Text>
79+
</Info>)
80+
})
81+
return task
82+
})
83+
.then(() => {
84+
report(<Assert key="upload and download event triggered" expect={true} actual={download && upload}/>)
6085
done()
6186
})
6287
})
@@ -87,6 +112,7 @@ describe('cancel task should work properly', (report, done) => {
87112
</Text>
88113
</Info>)
89114
})
115+
90116
let checkpoint1 = 0
91117
Timer.setTimeout(() => {
92118
task.cancel()

0 commit comments

Comments
 (0)