@@ -19,7 +19,7 @@ const through = require('through2')
19
19
const bl = require ( 'bl' )
20
20
21
21
module . exports = ( common ) => {
22
- describe ( '.files' , function ( ) {
22
+ describe . only ( '.files' , function ( ) {
23
23
this . timeout ( 5 * 1000 )
24
24
25
25
let ipfs
@@ -562,6 +562,7 @@ module.exports = (common) => {
562
562
directory . files [ 'jungle.txt' ] . toString ( ) ,
563
563
directory . files [ 'pp.txt' ] . toString ( )
564
564
] )
565
+ cb ( )
565
566
} )
566
567
}
567
568
] , done )
@@ -662,12 +663,41 @@ module.exports = (common) => {
662
663
} )
663
664
664
665
describe ( '.ls' , ( ) => {
665
- it ( 'with a base58 encoded string' , ( done ) => {
666
- const hash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
667
- ipfs . ls ( hash , ( err , files ) => {
666
+ before ( ( done ) => {
667
+ const content = ( name ) => ( {
668
+ path : `test-folder/${ name } ` ,
669
+ content : directory . files [ name ]
670
+ } )
671
+
672
+ const emptyDir = ( name ) => ( { path : `test-folder/${ name } ` } )
673
+
674
+ const dirs = [
675
+ content ( 'pp.txt' ) ,
676
+ content ( 'holmes.txt' ) ,
677
+ content ( 'jungle.txt' ) ,
678
+ content ( 'alice.txt' ) ,
679
+ emptyDir ( 'empty-folder' ) ,
680
+ content ( 'files/hello.txt' ) ,
681
+ content ( 'files/ipfs.txt' ) ,
682
+ emptyDir ( 'files/empty' )
683
+ ]
684
+
685
+ ipfs . files . add ( dirs , ( err , res ) => {
668
686
expect ( err ) . to . not . exist ( )
669
- files . forEach ( ( file ) => delete file . content )
670
- expect ( files ) . to . deep . equal ( [
687
+ const root = res [ res . length - 1 ]
688
+
689
+ expect ( root . path ) . to . equal ( 'test-folder' )
690
+ expect ( root . hash ) . to . equal ( directory . cid )
691
+ done ( )
692
+ } )
693
+ } )
694
+
695
+ it ( 'with a base58 encoded CID' , ( done ) => {
696
+ const cid = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
697
+ ipfs . ls ( cid , ( err , files ) => {
698
+ expect ( err ) . to . not . exist ( )
699
+
700
+ expect ( files ) . to . eql ( [
671
701
{ depth : 1 ,
672
702
name : 'alice.txt' ,
673
703
path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt' ,
@@ -703,7 +733,8 @@ module.exports = (common) => {
703
733
path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt' ,
704
734
size : 4551 ,
705
735
hash : 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn' ,
706
- type : 'file' } ] )
736
+ type : 'file' }
737
+ ] )
707
738
done ( )
708
739
} )
709
740
} )
0 commit comments