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

Commit

Permalink
test(files): add test to ensure meaningful error is thrown in cat()
Browse files Browse the repository at this point in the history
To verify changes discussed in https://github.com/ipfs/js-ipfs-api/issues/799#issuecomment-402086401, this commit
adds a test that checks `files.cat()` throws a meaningful error when a key or ipfs path with
unsupported encoding is given.

License: MIT
Signed-off-by: Pascal Precht pascal.precht@gmail.com
  • Loading branch information
0x-r4bbit committed Jul 18, 2018
1 parent 7ed2b58 commit 4585d39
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions js/src/files/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ module.exports = (createCommon, options) => {
})
})

it('should error on key/path with invalid encoding', () => {
const invalidCid = '/ipfs/QmUzdHisA7ouM8DM5rVAKursVK7t7tKeqDYGvmaCdJw5jEeesdlfjsldkfjsldkfjsdlkfjskldfj'

return ipfs.files.cat(invalidCid)
.catch((err) => {
expect(err).to.exist()
expect(err.toString()).to.contain('Error: selected encoding not supported')
})
})

it('should error on unknown path (promised)', () => {
return ipfs.files.cat(fixtures.smallFile.cid + '/does-not-exist')
.catch((err) => {
Expand Down

0 comments on commit 4585d39

Please sign in to comment.