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

Commit b3520cc

Browse files
committed
fix directory test
1 parent 6fdd2dc commit b3520cc

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

src/files.js

+38-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const through = require('through2')
1919
const bl = require('bl')
2020

2121
module.exports = (common) => {
22-
describe('.files', function () {
22+
describe.only('.files', function () {
2323
this.timeout(5 * 1000)
2424

2525
let ipfs
@@ -562,6 +562,7 @@ module.exports = (common) => {
562562
directory.files['jungle.txt'].toString(),
563563
directory.files['pp.txt'].toString()
564564
])
565+
cb()
565566
})
566567
}
567568
], done)
@@ -662,12 +663,41 @@ module.exports = (common) => {
662663
})
663664

664665
describe('.ls', () => {
665-
it('with a base58 encoded string', (done) => {
666-
const hash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
667-
ipfs.ls(hash, (err, files) => {
666+
before((done) => {
667+
const content = (name) => ({
668+
path: `test-folder/${name}`,
669+
content: directory.files[name]
670+
})
671+
672+
const emptyDir = (name) => ({ path: `test-folder/${name}` })
673+
674+
const dirs = [
675+
content('pp.txt'),
676+
content('holmes.txt'),
677+
content('jungle.txt'),
678+
content('alice.txt'),
679+
emptyDir('empty-folder'),
680+
content('files/hello.txt'),
681+
content('files/ipfs.txt'),
682+
emptyDir('files/empty')
683+
]
684+
685+
ipfs.files.add(dirs, (err, res) => {
668686
expect(err).to.not.exist()
669-
files.forEach((file) => delete file.content)
670-
expect(files).to.deep.equal([
687+
const root = res[res.length - 1]
688+
689+
expect(root.path).to.equal('test-folder')
690+
expect(root.hash).to.equal(directory.cid)
691+
done()
692+
})
693+
})
694+
695+
it('with a base58 encoded CID', (done) => {
696+
const cid = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
697+
ipfs.ls(cid, (err, files) => {
698+
expect(err).to.not.exist()
699+
700+
expect(files).to.eql([
671701
{ depth: 1,
672702
name: 'alice.txt',
673703
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt',
@@ -703,7 +733,8 @@ module.exports = (common) => {
703733
path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt',
704734
size: 4551,
705735
hash: 'QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn',
706-
type: 'file' } ])
736+
type: 'file' }
737+
])
707738
done()
708739
})
709740
})

0 commit comments

Comments
 (0)