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

Spec and Test update to support ipfs/js-ipfs#1229 #243

Merged
merged 3 commits into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SPEC/FILES.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ pull(
ipfsPath can be of type:

- [`cid`][cid] of type:
- a [CID](https://github.com/ipfs/js-cid) instance
- [Buffer][b], the raw Buffer of the cid
- String, the base58 encoded version of the cid
- String, including the ipfs handler, a cid and a path to traverse to, ie:
Expand Down Expand Up @@ -202,6 +203,7 @@ A great source of [examples][] can be found in the tests for this API.
ipfsPath can be of type:

- [`cid`][cid] of type:
- a [CID](https://github.com/ipfs/js-cid) instance
- [Buffer][b], the raw Buffer of the cid
- String, the base58 encoded version of the cid
- String, including the ipfs handler, a cid and a path to traverse to, ie:
Expand Down
11 changes: 11 additions & 0 deletions js/src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const through = require('through2')
const path = require('path')
const bl = require('bl')
const isNode = require('detect-node')
const CID = require('cids')

module.exports = (common) => {
describe('.files', function () {
Expand Down Expand Up @@ -375,6 +376,16 @@ module.exports = (common) => {
})
})

it('with a cid object', (done) => {
const cid = new CID(smallFile.cid)

ipfs.files.cat(cid, (err, data) => {
expect(err).to.not.exist()
expect(data.toString()).to.contain('Plz add me!')
done()
})
})

it('streams a large file', (done) => {
ipfs.files.cat(bigFile.cid, (err, data) => {
expect(err).to.not.exist()
Expand Down