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

Commit f8a1807

Browse files
committed
fix .ls test
1 parent 85bfde5 commit f8a1807

File tree

1 file changed

+18
-65
lines changed

1 file changed

+18
-65
lines changed

src/files.js

Lines changed: 18 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const through = require('through2')
1717
const Buffer = require('safe-buffer').Buffer
1818

1919
module.exports = (common) => {
20-
describe('.files', function () {
20+
describe.only('.files', function () {
2121
this.timeout(80 * 1000)
2222

2323
let smallFile
@@ -535,58 +535,6 @@ module.exports = (common) => {
535535
})
536536
})
537537
})
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-
})
590538
})
591539

592540
describe('promise API', () => {
@@ -684,15 +632,20 @@ module.exports = (common) => {
684632
})
685633

686634
describe('.ls', () => {
687-
it('with a base58 encoded string', () => {
635+
it('with a base58 encoded string', (done) => {
688636
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,
696649
name: 'alice.txt',
697650
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt',
698651
size: 11696,
@@ -727,10 +680,10 @@ module.exports = (common) => {
727680
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt',
728681
size: 4551,
729682
hash: 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn',
730-
type: 'file' } ])
731-
resolve()
732-
}))
733-
})
683+
type: 'file'
684+
}
685+
])
686+
}
734687
})
735688
})
736689
})

0 commit comments

Comments
 (0)