|
@@ -473,6 +473,35 @@ describe('fs.slice test', (report, done) => {
|
473
|
473
|
|
474
|
474
|
})
|
475
|
475
|
|
|
476
|
+describe('#135 binary data to ascii file size checking', (report, done) => {
|
|
477
|
+
|
|
478
|
+ let file = null
|
|
479
|
+ let expectedSize = 0
|
|
480
|
+
|
|
481
|
+ RNFetchBlob.config({ fileCache : true })
|
|
482
|
+ .fetch('GET', `${TEST_SERVER_URL}/public/beethoven.mp3`)
|
|
483
|
+ .then((res) => {
|
|
484
|
+ file = res.path()
|
|
485
|
+ return fs.stat(file)
|
|
486
|
+ })
|
|
487
|
+ .then((stat) => {
|
|
488
|
+ expectedSize = Math.floor(stat.size)
|
|
489
|
+ return fs.readStream(file, 'ascii')
|
|
490
|
+ })
|
|
491
|
+ .then((stream) => {
|
|
492
|
+ let actual = 0
|
|
493
|
+ stream.open()
|
|
494
|
+ stream.onData((chunk) => {
|
|
495
|
+ actual += chunk.length
|
|
496
|
+ })
|
|
497
|
+ stream.onEnd(() => {
|
|
498
|
+ report(<Assert key="check mp3 file size" expect={expectedSize} actual={actual}/>)
|
|
499
|
+ done()
|
|
500
|
+ })
|
|
501
|
+ })
|
|
502
|
+
|
|
503
|
+})
|
|
504
|
+
|
476
|
505
|
|
477
|
506
|
function getASCIIArray(str) {
|
478
|
507
|
let r = []
|