Ben Hsieh 8 gadus atpakaļ
vecāks
revīzija
ea2b11a860
1 mainītis faili ar 43 papildinājumiem un 0 dzēšanām
  1. 43
    0
      test/test-0.10.0.js

+ 43
- 0
test/test-0.10.0.js Parādīt failu

@@ -127,3 +127,46 @@ describe('#171 appendExt verify', (report, done) => {
127 127
   })
128 128
 
129 129
 })
130
+
131
+describe('#173 issue with append option', (report, done) => {
132
+  let dest = dirs.DocumentDir + '/tmp' + Date.now()
133
+  RNFetchBlob.config({
134
+    path : dest,
135
+    overwrite : true
136
+  })
137
+  .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
138
+  .then((res) => fs.stat(res.path()))
139
+  .then((stat) => {
140
+    report(<Assert key="file size check #1" expect="23975" actual={stat.size}/>)
141
+    return RNFetchBlob.config({
142
+      path : dest,
143
+      overwrite : false
144
+    })
145
+    .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
146
+  })
147
+  .then((res) => fs.stat(res.path()))
148
+  .then((stat) => {
149
+    report(<Assert key="file size check #2" expect="47950" actual={stat.size}/>)
150
+    return RNFetchBlob.config({
151
+      path : dest,
152
+      overwrite : true
153
+    })
154
+    .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
155
+  })
156
+  .then((res) => fs.stat(res.path()))
157
+  .then((stat) => {
158
+    report(<Assert key="file size check #3" expect="23975" actual={stat.size}/>)
159
+    return RNFetchBlob.config({
160
+      path : dest,
161
+    })
162
+    .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
163
+  })
164
+  .then((res) => fs.stat(res.path()))
165
+  .then((stat) => {
166
+    report(<Assert key="it should successfully overwrite existing file without config"
167
+      expect="23975"
168
+      actual={stat.size}/>)
169
+    done()
170
+  })
171
+
172
+})