@@ -17,7 +17,7 @@ const through = require('through2')
17
17
const Buffer = require ( 'safe-buffer' ) . Buffer
18
18
19
19
module . exports = ( common ) => {
20
- describe ( '.files' , function ( ) {
20
+ describe . only ( '.files' , function ( ) {
21
21
this . timeout ( 80 * 1000 )
22
22
23
23
let smallFile
@@ -535,58 +535,6 @@ 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
describe ( 'promise API' , ( ) => {
@@ -684,15 +632,20 @@ module.exports = (common) => {
684
632
} )
685
633
686
634
describe ( '.ls' , ( ) => {
687
- it ( 'with a base58 encoded string' , ( ) => {
635
+ it ( 'with a base58 encoded string' , ( done ) => {
688
636
const hash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
689
- return ipfs . files . ls ( hash ) . then ( ( stream ) => {
690
- return new Promise ( ( resolve , reject ) => {
691
- stream . pipe ( concat ( ( files ) => {
692
- expect ( files ) . to . be . length ( 6 )
693
- // remove content so that we can compare
694
- files . forEach ( ( file ) => delete file . content )
695
- expect ( files ) . to . deep . equal ( [ { depth : 1 ,
637
+ ipfs . ls ( hash , ( err , stream ) => {
638
+ expect ( err ) . to . not . exist ( )
639
+
640
+ stream . pipe ( concat ( gotFiles ) )
641
+
642
+ function gotFiles ( files ) {
643
+ expect ( files ) . to . be . length ( 6 )
644
+ // remove content so that we can compare
645
+ files . forEach ( ( file ) => delete file . content )
646
+
647
+ expect ( files ) . to . eql ( [
648
+ { depth : 1 ,
696
649
name : 'alice.txt' ,
697
650
path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt' ,
698
651
size : 11696 ,
@@ -727,10 +680,10 @@ module.exports = (common) => {
727
680
path : 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt' ,
728
681
size : 4551 ,
729
682
hash : 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn' ,
730
- type : 'file' } ] )
731
- resolve ( )
732
- } ) )
733
- } )
683
+ type : 'file'
684
+ }
685
+ ] )
686
+ }
734
687
} )
735
688
} )
736
689
} )
0 commit comments