@@ -535,6 +535,59 @@ module.exports = (common) => {
535
535
} )
536
536
} )
537
537
} )
538
+
539
+ describe ( '.ls' , ( ) => {
540
+ it ( 'with a base58 encoded string' , ( ) => {
541
+ const hash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
542
+ return ipfs . files . ls ( hash ) . then ( ( stream ) => {
543
+ return new Promise ( ( resolve , reject ) => {
544
+ stream . pipe ( concat ( ( files ) => {
545
+ expect ( files ) . to . be . length ( 6 )
546
+ // remove content so that we can compare
547
+ files . forEach ( ( file ) => delete file . content )
548
+ expect ( files ) . to . deep . equal ( [ { depth : 1 ,
549
+ name : 'alice.txt' ,
550
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt' ,
551
+ size : 11696 ,
552
+ hash : 'QmZyUEQVuRK3XV7L9Dk26pg6RVSgaYkiSTEdnT2kZZdwoi' ,
553
+ type : 'file' } ,
554
+ { depth : 1 ,
555
+ name : 'empty-folder' ,
556
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/empty-folder' ,
557
+ size : 4 ,
558
+ hash : 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn' ,
559
+ type : 'dir' } ,
560
+ { depth : 1 ,
561
+ name : 'files' ,
562
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files' ,
563
+ size : 183 ,
564
+ hash : 'QmZ25UfTqXGz9RsEJFg7HUAuBcmfx5dQZDXQd2QEZ8Kj74' ,
565
+ type : 'dir' } ,
566
+ { depth : 1 ,
567
+ name : 'holmes.txt' ,
568
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/holmes.txt' ,
569
+ size : 582072 ,
570
+ hash : 'QmR4nFjTu18TyANgC65ArNWp5Yaab1gPzQ4D8zp7Kx3vhr' ,
571
+ type : 'file' } ,
572
+ { depth : 1 ,
573
+ name : 'jungle.txt' ,
574
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt' ,
575
+ size : 2305 ,
576
+ hash : 'QmT6orWioMiSqXXPGsUi71CKRRUmJ8YkuueV2DPV34E9y9' ,
577
+ type : 'file' } ,
578
+ { depth : 1 ,
579
+ name : 'pp.txt' ,
580
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt' ,
581
+ size : 4551 ,
582
+ hash : 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn' ,
583
+ type : 'file' } ] )
584
+ resolve ( )
585
+ } ) )
586
+ } )
587
+ } )
588
+ } )
589
+ } )
590
+
538
591
} )
539
592
540
593
describe ( 'promise API' , ( ) => {
@@ -630,6 +683,58 @@ module.exports = (common) => {
630
683
} )
631
684
} )
632
685
} )
686
+
687
+ describe ( '.ls' , ( ) => {
688
+ it ( 'with a base58 encoded string' , ( ) => {
689
+ const hash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
690
+ return ipfs . files . ls ( hash ) . then ( ( stream ) => {
691
+ return new Promise ( ( resolve , reject ) => {
692
+ stream . pipe ( concat ( ( files ) => {
693
+ expect ( files ) . to . be . length ( 6 )
694
+ // remove content so that we can compare
695
+ files . forEach ( ( file ) => delete file . content )
696
+ expect ( files ) . to . deep . equal ( [ { depth : 1 ,
697
+ name : 'alice.txt' ,
698
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt' ,
699
+ size : 11696 ,
700
+ hash : 'QmZyUEQVuRK3XV7L9Dk26pg6RVSgaYkiSTEdnT2kZZdwoi' ,
701
+ type : 'file' } ,
702
+ { depth : 1 ,
703
+ name : 'empty-folder' ,
704
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/empty-folder' ,
705
+ size : 4 ,
706
+ hash : 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn' ,
707
+ type : 'dir' } ,
708
+ { depth : 1 ,
709
+ name : 'files' ,
710
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files' ,
711
+ size : 183 ,
712
+ hash : 'QmZ25UfTqXGz9RsEJFg7HUAuBcmfx5dQZDXQd2QEZ8Kj74' ,
713
+ type : 'dir' } ,
714
+ { depth : 1 ,
715
+ name : 'holmes.txt' ,
716
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/holmes.txt' ,
717
+ size : 582072 ,
718
+ hash : 'QmR4nFjTu18TyANgC65ArNWp5Yaab1gPzQ4D8zp7Kx3vhr' ,
719
+ type : 'file' } ,
720
+ { depth : 1 ,
721
+ name : 'jungle.txt' ,
722
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt' ,
723
+ size : 2305 ,
724
+ hash : 'QmT6orWioMiSqXXPGsUi71CKRRUmJ8YkuueV2DPV34E9y9' ,
725
+ type : 'file' } ,
726
+ { depth : 1 ,
727
+ name : 'pp.txt' ,
728
+ path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt' ,
729
+ size : 4551 ,
730
+ hash : 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn' ,
731
+ type : 'file' } ] )
732
+ resolve ( )
733
+ } ) )
734
+ } )
735
+ } )
736
+ } )
737
+ } )
633
738
} )
634
739
} )
635
740
}
0 commit comments