|
@@ -132,15 +132,19 @@ describe('create file API test', (report, done) => {
|
132
|
132
|
|
133
|
133
|
describe('mkdir and isDir API test', (report, done) => {
|
134
|
134
|
let p = dirs.DocumentDir + '/mkdir-test-' + Date.now()
|
135
|
|
- fs.mkdir(p + '/mkdir').then((err) => {
|
|
135
|
+ fs.mkdir(p).then((err) => {
|
136
|
136
|
report(<Assert key="folder should be created without error"
|
137
|
137
|
expect={undefined}
|
138
|
138
|
actual={err} />)
|
139
|
|
- return fs.isDir(p + '/mkdir')
|
|
139
|
+ return fs.exists(p)
|
|
140
|
+ })
|
|
141
|
+ .then((exist) => {
|
|
142
|
+ report(<Assert key="mkdir should work correctly" expect={true} actual={exist} />)
|
|
143
|
+ return fs.isDir(p)
|
140
|
144
|
})
|
141
|
145
|
.then((isDir) => {
|
142
|
146
|
report(<Assert key="isDir should work correctly" expect={true} actual={isDir} />)
|
143
|
|
- return fs.mkdir(p + '/mkdir')
|
|
147
|
+ return fs.mkdir(p)
|
144
|
148
|
})
|
145
|
149
|
.then()
|
146
|
150
|
.catch((err) => {
|
|
@@ -164,14 +168,14 @@ describe('unlink and mkdir API test', (report, done) => {
|
164
|
168
|
})
|
165
|
169
|
.then((exist) => {
|
166
|
170
|
report(<Assert key="file removed" expect={false} actual={exist} />)
|
167
|
|
- return fs.mkdir(p + '/dir')
|
|
171
|
+ return fs.mkdir(p + '-dir')
|
168
|
172
|
})
|
169
|
|
- .then((err) => fs.exists(p + '/dir'))
|
|
173
|
+ .then((err) => fs.exists(p + '-dir'))
|
170
|
174
|
.then((exist) => {
|
171
|
175
|
report(<Assert key="mkdir should success" expect={true} actual={exist} />)
|
172
|
|
- return fs.unlink(p + '/dir')
|
|
176
|
+ return fs.unlink(p + '-dir')
|
173
|
177
|
})
|
174
|
|
- .then(() => fs.exists(p + '/dir'))
|
|
178
|
+ .then(() => fs.exists(p + '-dir'))
|
175
|
179
|
.then((exist) => {
|
176
|
180
|
report(<Assert key="folder should be removed" expect={false} actual={exist} />)
|
177
|
181
|
done()
|
|
@@ -209,9 +213,9 @@ describe('write stream API test', (report, done) => {
|
209
|
213
|
fs.writeStream(p, 'base64', false)
|
210
|
214
|
.then((ws) => {
|
211
|
215
|
for(let i = 0; i< 100; i++) {
|
212
|
|
- expect += RNFetchBlob.base64.encode(i)
|
213
|
|
- ws.write(RNFetchBlob.base64.encode(i))
|
|
216
|
+ expect += String(i)
|
214
|
217
|
}
|
|
218
|
+ ws.write(RNFetchBlob.base64.encode(expect))
|
215
|
219
|
return ws.close()
|
216
|
220
|
})
|
217
|
221
|
.then(() => {
|
|
@@ -221,10 +225,11 @@ describe('write stream API test', (report, done) => {
|
221
|
225
|
d2 += chunk
|
222
|
226
|
})
|
223
|
227
|
rs.onEnd(() => {
|
|
228
|
+ console.log(RNFetchBlob.base64.encode(expect),d2)
|
224
|
229
|
report(
|
225
|
230
|
<Assert key="file should be overwritten by base64 encoded data"
|
226
|
|
- expect={expect}
|
227
|
|
- actual={RNFetchBlob.base64.decode(d2)} />)
|
|
231
|
+ expect={RNFetchBlob.base64.encode(expect)}
|
|
232
|
+ actual={d2} />)
|
228
|
233
|
done()
|
229
|
234
|
})
|
230
|
235
|
})
|