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

Commit a58ac3c

Browse files
committed
Check directory contents in "get" test.
1 parent 46fa99a commit a58ac3c

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

src/files.js

+32-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const concat = require('concat-stream')
1111
const through = require('through2')
1212

1313
module.exports = (common) => {
14-
describe.only('.files', () => {
14+
describe('.files', () => {
1515
let smallFile
1616
let bigFile
1717
let directoryContent
@@ -185,7 +185,7 @@ module.exports = (common) => {
185185
const hash = 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'
186186
ipfs.cat(hash, (err, stream) => {
187187
expect(err).to.not.exist
188-
stream.pipe(bl((err, data) => {
188+
stream.pipe(concat((data) => {
189189
expect(err).to.not.exist
190190
expect(data.toString()).to.contain('Check out some of the other files in this directory:')
191191
done()
@@ -197,21 +197,23 @@ module.exports = (common) => {
197197
const hash = 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq'
198198
ipfs.cat(hash, (err, stream) => {
199199
expect(err).to.not.exist
200-
stream.pipe(bl((err, data) => {
200+
stream.pipe(concat((data) => {
201201
expect(err).to.not.exist
202202
expect(data).to.deep.equal(bigFile)
203203
done()
204204
}))
205205
})
206+
})
206207

207-
it('with a multihash', (done) => {
208-
const mhBuf = new Buffer(bs58.decode('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'))
209-
ipfs.cat(mhBuf, (err, stream) => {
210-
expect(err).to.not.exist
211-
stream.pipe(concat((data) => {
212-
expect(data.toString()).to.contain('Check out some of the other files in this directory:')
213-
done()
214-
}))
208+
it('with a multihash', (done) => {
209+
const mhBuf = new Buffer(bs58.decode('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'))
210+
ipfs.cat(mhBuf, (err, stream) => {
211+
expect(err).to.not.exist
212+
stream.pipe(concat((data) => {
213+
expect(data.toString()).to.contain('Check out some of the other files in this directory:')
214+
done()
215+
}))
216+
})
215217
})
216218
})
217219
})
@@ -306,7 +308,7 @@ module.exports = (common) => {
306308
expect(err).to.not.exist
307309
stream.pipe(concat((files) => {
308310
expect(files).to.be.length(1)
309-
expect(files[0].path).to.deep.equal(hash)
311+
expect(files[0].path).to.deep.equal(mhBuf)
310312
files[0].content.pipe(concat((content) => {
311313
expect(content.toString()).to.contain('Check out some of the other files in this directory:')
312314
done()
@@ -360,6 +362,7 @@ module.exports = (common) => {
360362
next()
361363
}
362364
}, () => {
365+
// Check paths
363366
var paths = files.map((file) => {
364367
return file.path
365368
})
@@ -375,6 +378,23 @@ module.exports = (common) => {
375378
'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt',
376379
'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt',
377380
])
381+
382+
// Check contents
383+
var contents = files.map((file) => {
384+
return file.content ? file.content : null
385+
})
386+
expect(contents).to.deep.equal([
387+
null,
388+
directoryContent['alice.txt'],
389+
null,
390+
null,
391+
null,
392+
directoryContent['files/hello.txt'],
393+
directoryContent['files/ipfs.txt'],
394+
directoryContent['holmes.txt'],
395+
directoryContent['jungle.txt'],
396+
directoryContent['pp.txt'],
397+
])
378398
done()
379399
}))
380400
})

0 commit comments

Comments
 (0)