瀏覽代碼

Add test case for #248

Ben Hsieh 8 年之前
父節點
當前提交
1bf5e81111
共有 2 個檔案被更改,包括 42 行新增0 行删除
  1. 二進制
      test-server/public/issue-248-dummy.zip
  2. 42
    0
      test/test-0.10.2.js

二進制
test-server/public/issue-248-dummy.zip 查看文件


+ 42
- 0
test/test-0.10.2.js 查看文件

@@ -110,3 +110,45 @@ describe('#247 binary data UTF8 encoding causes app crash', (report, done) => {
110 110
   })
111 111
 
112 112
 })
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
+})