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

Commit 76e7582

Browse files
committed
Add test case for #120
1 parent c72e6d7 commit 76e7582

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

test/test-0.7.0.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('Upload and download large file', (report, done) => {
4545
if(Date.now() - deb < 1000)
4646
return
4747
deb = Date.now()
48+
console.log('download', now, total)
4849
report(<Info uid="200" key="progress">
4950
<Text>
5051
{`download ${now} / ${total} bytes (${Math.floor(now / (Date.now() - begin))} kb/s) ${(100*now/total).toFixed(2)}%`}
@@ -72,6 +73,7 @@ describe('Upload and download large file', (report, done) => {
7273
if(Date.now() - deb < 1000)
7374
return
7475
deb = Date.now()
76+
console.log('upload', now, total)
7577
report(<Info uid="300" key="upload progress">
7678
<Text>
7779
{`upload ${now} / ${total} bytes (${Math.floor(now / (Date.now() - begin))} kb/s) ${(100*now/total).toFixed(2)}%`}

test/test-0.9.4.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,6 @@ describe('#118 ', (report, done) => {
117117
cache = res.path()
118118
return fs.readStream(cache, 'utf8', 102400)
119119
})
120-
// .then((res) => {
121-
// cache = res.path()
122-
// return fs.readFile(cache, 'utf8')
123-
// })
124-
// .then(() => {
125-
// report(<Info key="good" />)
126-
// done()
127-
// fs.unlink(cache)
128-
// })
129120
.then((stream) => {
130121
stream.open()
131122
start = Date.now()
@@ -153,3 +144,29 @@ describe('#118 ', (report, done) => {
153144
})
154145

155146
})
147+
148+
describe('issue #120 upload progress should work when sending body as-is', (report, done) => {
149+
150+
let data = RNTest.prop('image')
151+
let tick = 0
152+
153+
let task = RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
154+
Authorization : `Bearer ${DROPBOX_TOKEN}`,
155+
'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+FILENAME+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
156+
'Content-Type' : 'text/plain; charset=dropbox-cors-hack',
157+
}, data)
158+
159+
task.uploadProgress((current, total) => {
160+
tick ++
161+
})
162+
.then((res) => {
163+
let resp = res.json()
164+
report(
165+
<Info key="viewer"><Text>{JSON.stringify(resp)}</Text></Info>,
166+
<Assert key="event should be triggered"
167+
expect={tick}
168+
comparer={Comparer.greater} actual={0}/>)
169+
done()
170+
})
171+
172+
})

0 commit comments

Comments
 (0)