@@ -11,7 +11,7 @@ const concat = require('concat-stream')
11
11
const through = require ( 'through2' )
12
12
13
13
module . exports = ( common ) => {
14
- describe . only ( '.files' , ( ) => {
14
+ describe ( '.files' , ( ) => {
15
15
let smallFile
16
16
let bigFile
17
17
let directoryContent
@@ -185,7 +185,7 @@ module.exports = (common) => {
185
185
const hash = 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'
186
186
ipfs . cat ( hash , ( err , stream ) => {
187
187
expect ( err ) . to . not . exist
188
- stream . pipe ( bl ( ( err , data ) => {
188
+ stream . pipe ( concat ( ( data ) => {
189
189
expect ( err ) . to . not . exist
190
190
expect ( data . toString ( ) ) . to . contain ( 'Check out some of the other files in this directory:' )
191
191
done ( )
@@ -197,21 +197,23 @@ module.exports = (common) => {
197
197
const hash = 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq'
198
198
ipfs . cat ( hash , ( err , stream ) => {
199
199
expect ( err ) . to . not . exist
200
- stream . pipe ( bl ( ( err , data ) => {
200
+ stream . pipe ( concat ( ( data ) => {
201
201
expect ( err ) . to . not . exist
202
202
expect ( data ) . to . deep . equal ( bigFile )
203
203
done ( )
204
204
} ) )
205
205
} )
206
+ } )
206
207
207
- it ( 'with a multihash' , ( done ) => {
208
- const mhBuf = new Buffer ( bs58 . decode ( 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB' ) )
209
- ipfs . cat ( mhBuf , ( err , stream ) => {
210
- expect ( err ) . to . not . exist
211
- stream . pipe ( concat ( ( data ) => {
212
- expect ( data . toString ( ) ) . to . contain ( 'Check out some of the other files in this directory:' )
213
- done ( )
214
- } ) )
208
+ it ( 'with a multihash' , ( done ) => {
209
+ const mhBuf = new Buffer ( bs58 . decode ( 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB' ) )
210
+ ipfs . cat ( mhBuf , ( err , stream ) => {
211
+ expect ( err ) . to . not . exist
212
+ stream . pipe ( concat ( ( data ) => {
213
+ expect ( data . toString ( ) ) . to . contain ( 'Check out some of the other files in this directory:' )
214
+ done ( )
215
+ } ) )
216
+ } )
215
217
} )
216
218
} )
217
219
} )
@@ -306,7 +308,7 @@ module.exports = (common) => {
306
308
expect ( err ) . to . not . exist
307
309
stream . pipe ( concat ( ( files ) => {
308
310
expect ( files ) . to . be . length ( 1 )
309
- expect ( files [ 0 ] . path ) . to . deep . equal ( hash )
311
+ expect ( files [ 0 ] . path ) . to . deep . equal ( mhBuf )
310
312
files [ 0 ] . content . pipe ( concat ( ( content ) => {
311
313
expect ( content . toString ( ) ) . to . contain ( 'Check out some of the other files in this directory:' )
312
314
done ( )
@@ -360,6 +362,7 @@ module.exports = (common) => {
360
362
next ( )
361
363
}
362
364
} , ( ) => {
365
+ // Check paths
363
366
var paths = files . map ( ( file ) => {
364
367
return file . path
365
368
} )
@@ -375,6 +378,23 @@ module.exports = (common) => {
375
378
'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt' ,
376
379
'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt' ,
377
380
] )
381
+
382
+ // Check contents
383
+ var contents = files . map ( ( file ) => {
384
+ return file . content ? file . content : null
385
+ } )
386
+ expect ( contents ) . to . deep . equal ( [
387
+ null ,
388
+ directoryContent [ 'alice.txt' ] ,
389
+ null ,
390
+ null ,
391
+ null ,
392
+ directoryContent [ 'files/hello.txt' ] ,
393
+ directoryContent [ 'files/ipfs.txt' ] ,
394
+ directoryContent [ 'holmes.txt' ] ,
395
+ directoryContent [ 'jungle.txt' ] ,
396
+ directoryContent [ 'pp.txt' ] ,
397
+ ] )
378
398
done ( )
379
399
} ) )
380
400
} )
0 commit comments