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

Commit

Permalink
Add test case for #120
Browse files Browse the repository at this point in the history
  • Loading branch information
wkh237 committed Sep 5, 2016
1 parent c72e6d7 commit 76e7582
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
2 changes: 2 additions & 0 deletions test/test-0.7.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('Upload and download large file', (report, done) => {
if(Date.now() - deb < 1000)
return
deb = Date.now()
console.log('download', now, total)
report(<Info uid="200" key="progress">
<Text>
{`download ${now} / ${total} bytes (${Math.floor(now / (Date.now() - begin))} kb/s) ${(100*now/total).toFixed(2)}%`}
Expand Down Expand Up @@ -72,6 +73,7 @@ describe('Upload and download large file', (report, done) => {
if(Date.now() - deb < 1000)
return
deb = Date.now()
console.log('upload', now, total)
report(<Info uid="300" key="upload progress">
<Text>
{`upload ${now} / ${total} bytes (${Math.floor(now / (Date.now() - begin))} kb/s) ${(100*now/total).toFixed(2)}%`}
Expand Down
35 changes: 26 additions & 9 deletions test/test-0.9.4.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ describe('#118 ', (report, done) => {
cache = res.path()
return fs.readStream(cache, 'utf8', 102400)
})
// .then((res) => {
// cache = res.path()
// return fs.readFile(cache, 'utf8')
// })
// .then(() => {
// report(<Info key="good" />)
// done()
// fs.unlink(cache)
// })
.then((stream) => {
stream.open()
start = Date.now()
Expand Down Expand Up @@ -153,3 +144,29 @@ describe('#118 ', (report, done) => {
})

})

describe('issue #120 upload progress should work when sending body as-is', (report, done) => {

let data = RNTest.prop('image')
let tick = 0

let task = RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
Authorization : `Bearer ${DROPBOX_TOKEN}`,
'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+FILENAME+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
'Content-Type' : 'text/plain; charset=dropbox-cors-hack',
}, data)

task.uploadProgress((current, total) => {
tick ++
})
.then((res) => {
let resp = res.json()
report(
<Info key="viewer"><Text>{JSON.stringify(resp)}</Text></Info>,
<Assert key="event should be triggered"
expect={tick}
comparer={Comparer.greater} actual={0}/>)
done()
})

})

0 comments on commit 76e7582

Please sign in to comment.