@@ -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
@@ -711,12 +711,41 @@ module.exports = (common) => {
711
711
} )
712
712
713
713
describe ( '.ls' , ( ) => {
714
- it ( 'with a base58 encoded string' , ( done ) => {
715
- const hash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
716
- ipfs . ls ( hash , ( err , files ) => {
714
+ before ( ( done ) => {
715
+ const content = ( name ) => ( {
716
+ path : `test-folder/${ name } ` ,
717
+ content : directory . files [ name ]
718
+ } )
719
+
720
+ const emptyDir = ( name ) => ( { path : `test-folder/${ name } ` } )
721
+
722
+ const dirs = [
723
+ content ( 'pp.txt' ) ,
724
+ content ( 'holmes.txt' ) ,
725
+ content ( 'jungle.txt' ) ,
726
+ content ( 'alice.txt' ) ,
727
+ emptyDir ( 'empty-folder' ) ,
728
+ content ( 'files/hello.txt' ) ,
729
+ content ( 'files/ipfs.txt' ) ,
730
+ emptyDir ( 'files/empty' )
731
+ ]
732
+
733
+ ipfs . files . add ( dirs , ( err , res ) => {
717
734
expect ( err ) . to . not . exist ( )
718
- files . forEach ( ( file ) => delete file . content )
719
- expect ( files ) . to . deep . equal ( [
735
+ const root = res [ res . length - 1 ]
736
+
737
+ expect ( root . path ) . to . equal ( 'test-folder' )
738
+ expect ( root . hash ) . to . equal ( directory . cid )
739
+ done ( )
740
+ } )
741
+ } )
742
+
743
+ it ( 'with a base58 encoded CID' , ( done ) => {
744
+ const cid = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
745
+ ipfs . ls ( cid , ( err , files ) => {
746
+ expect ( err ) . to . not . exist ( )
747
+
748
+ expect ( files ) . to . eql ( [
720
749
{ depth : 1 ,
721
750
name : 'alice.txt' ,
722
751
path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt' ,
@@ -752,7 +781,8 @@ module.exports = (common) => {
752
781
path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt' ,
753
782
size : 4551 ,
754
783
hash : 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn' ,
755
- type : 'file' } ] )
784
+ type : 'file' }
785
+ ] )
756
786
done ( )
757
787
} )
758
788
} )
0 commit comments