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

Commit 1bf5e81

Browse files
committed
Add test case for #248
1 parent dc17e30 commit 1bf5e81

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
16.1 MB
Binary file not shown.

test/test-0.10.2.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,45 @@ describe('#247 binary data UTF8 encoding causes app crash', (report, done) => {
110110
})
111111

112112
})
113+
114+
115+
describe('#248 create blob from file has spaces in filename', (report, done) => {
116+
117+
let source = '',
118+
size = 0,
119+
path = 'archive image.zip'
120+
RNFetchBlob
121+
.config({path : fs.dirs.DocumentDir +'/' + path})
122+
.fetch('GET', `${TEST_SERVER_URL}/public/issue-248-dummy.zip`)
123+
.then((res) => {
124+
source = res.path();
125+
console.log('source=', source)
126+
window.Blob = RNFetchBlob.polyfill.Blob;
127+
return Blob.build(RNFetchBlob.wrap(source), { type : 'application/zip'})
128+
})
129+
.then((b) => {
130+
console.log(b)
131+
size = b.size
132+
return fs.stat(b._ref)
133+
})
134+
.then((stat) => {
135+
report(<Assert key="blob created without error"
136+
expect={stat.size} actual={size}/>)
137+
return RNFetchBlob.fetch('POST',
138+
`${TEST_SERVER_URL}/upload-form`,
139+
{
140+
'Content-Type' : 'multipart/form-data'
141+
}, [
142+
{
143+
name : 'file',
144+
filename : 'file name '+Platform.OS+'.zip',
145+
type : 'application/zip',
146+
data : RNFetchBlob.wrap(source)
147+
}
148+
])
149+
})
150+
.then(() => {
151+
done()
152+
})
153+
154+
})

0 commit comments

Comments
 (0)