Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 9126076

Browse files
pgtedaviddias
authored andcommitted
fixed .ls spec (#168)
1 parent 6849a67 commit 9126076

File tree

1 file changed

+48
-57
lines changed

1 file changed

+48
-57
lines changed

src/files.js

+48-57
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,54 @@ module.exports = (common) => {
535535
})
536536
})
537537
})
538+
539+
describe('.ls', () => {
540+
it('with a base58 encoded string', (done) => {
541+
const hash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
542+
ipfs.ls(hash, (err, files) => {
543+
expect(err).to.not.exist()
544+
files.forEach((file) => delete file.content)
545+
expect(files).to.deep.equal([
546+
{ depth: 1,
547+
name: 'alice.txt',
548+
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt',
549+
size: 11696,
550+
hash: 'QmZyUEQVuRK3XV7L9Dk26pg6RVSgaYkiSTEdnT2kZZdwoi',
551+
type: 'file' },
552+
{ depth: 1,
553+
name: 'empty-folder',
554+
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/empty-folder',
555+
size: 4,
556+
hash: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn',
557+
type: 'dir' },
558+
{ depth: 1,
559+
name: 'files',
560+
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files',
561+
size: 183,
562+
hash: 'QmZ25UfTqXGz9RsEJFg7HUAuBcmfx5dQZDXQd2QEZ8Kj74',
563+
type: 'dir' },
564+
{ depth: 1,
565+
name: 'holmes.txt',
566+
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/holmes.txt',
567+
size: 582072,
568+
hash: 'QmR4nFjTu18TyANgC65ArNWp5Yaab1gPzQ4D8zp7Kx3vhr',
569+
type: 'file' },
570+
{ depth: 1,
571+
name: 'jungle.txt',
572+
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt',
573+
size: 2305,
574+
hash: 'QmT6orWioMiSqXXPGsUi71CKRRUmJ8YkuueV2DPV34E9y9',
575+
type: 'file' },
576+
{ depth: 1,
577+
name: 'pp.txt',
578+
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt',
579+
size: 4551,
580+
hash: 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn',
581+
type: 'file' } ])
582+
done()
583+
})
584+
})
585+
})
538586
})
539587

540588
describe('promise API', () => {
@@ -630,63 +678,6 @@ module.exports = (common) => {
630678
})
631679
})
632680
})
633-
634-
describe('.ls', () => {
635-
it('with a base58 encoded string', (done) => {
636-
const hash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
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,
649-
name: 'alice.txt',
650-
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt',
651-
size: 11696,
652-
hash: 'QmZyUEQVuRK3XV7L9Dk26pg6RVSgaYkiSTEdnT2kZZdwoi',
653-
type: 'file' },
654-
{ depth: 1,
655-
name: 'empty-folder',
656-
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/empty-folder',
657-
size: 4,
658-
hash: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn',
659-
type: 'dir' },
660-
{ depth: 1,
661-
name: 'files',
662-
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files',
663-
size: 183,
664-
hash: 'QmZ25UfTqXGz9RsEJFg7HUAuBcmfx5dQZDXQd2QEZ8Kj74',
665-
type: 'dir' },
666-
{ depth: 1,
667-
name: 'holmes.txt',
668-
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/holmes.txt',
669-
size: 582072,
670-
hash: 'QmR4nFjTu18TyANgC65ArNWp5Yaab1gPzQ4D8zp7Kx3vhr',
671-
type: 'file' },
672-
{ depth: 1,
673-
name: 'jungle.txt',
674-
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt',
675-
size: 2305,
676-
hash: 'QmT6orWioMiSqXXPGsUi71CKRRUmJ8YkuueV2DPV34E9y9',
677-
type: 'file' },
678-
{ depth: 1,
679-
name: 'pp.txt',
680-
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt',
681-
size: 4551,
682-
hash: 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn',
683-
type: 'file'
684-
}
685-
])
686-
}
687-
})
688-
})
689-
})
690681
})
691682
})
692683
}

0 commit comments

Comments
 (0)