diff --git a/src/files.js b/src/files.js index 07e08226..bf78c2c2 100644 --- a/src/files.js +++ b/src/files.js @@ -11,7 +11,7 @@ const concat = require('concat-stream') const through = require('through2') module.exports = (common) => { - describe.only('.files', () => { + describe('.files', () => { let smallFile let bigFile let directoryContent @@ -185,7 +185,7 @@ module.exports = (common) => { const hash = 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB' ipfs.cat(hash, (err, stream) => { expect(err).to.not.exist - stream.pipe(bl((err, data) => { + stream.pipe(concat((data) => { expect(err).to.not.exist expect(data.toString()).to.contain('Check out some of the other files in this directory:') done() @@ -197,21 +197,23 @@ module.exports = (common) => { const hash = 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq' ipfs.cat(hash, (err, stream) => { expect(err).to.not.exist - stream.pipe(bl((err, data) => { + stream.pipe(concat((data) => { expect(err).to.not.exist expect(data).to.deep.equal(bigFile) done() })) }) + }) - it('with a multihash', (done) => { - const mhBuf = new Buffer(bs58.decode('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB')) - ipfs.cat(mhBuf, (err, stream) => { - expect(err).to.not.exist - stream.pipe(concat((data) => { - expect(data.toString()).to.contain('Check out some of the other files in this directory:') - done() - })) + it('with a multihash', (done) => { + const mhBuf = new Buffer(bs58.decode('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB')) + ipfs.cat(mhBuf, (err, stream) => { + expect(err).to.not.exist + stream.pipe(concat((data) => { + expect(data.toString()).to.contain('Check out some of the other files in this directory:') + done() + })) + }) }) }) }) @@ -306,7 +308,7 @@ module.exports = (common) => { expect(err).to.not.exist stream.pipe(concat((files) => { expect(files).to.be.length(1) - expect(files[0].path).to.deep.equal(hash) + expect(files[0].path).to.deep.equal(mhBuf) files[0].content.pipe(concat((content) => { expect(content.toString()).to.contain('Check out some of the other files in this directory:') done() @@ -360,6 +362,7 @@ module.exports = (common) => { next() } }, () => { + // Check paths var paths = files.map((file) => { return file.path }) @@ -375,6 +378,23 @@ module.exports = (common) => { 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt', 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt', ]) + + // Check contents + var contents = files.map((file) => { + return file.content ? file.content : null + }) + expect(contents).to.deep.equal([ + null, + directoryContent['alice.txt'], + null, + null, + null, + directoryContent['files/hello.txt'], + directoryContent['files/ipfs.txt'], + directoryContent['holmes.txt'], + directoryContent['jungle.txt'], + directoryContent['pp.txt'], + ]) done() })) })