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

test(files): add test to ensure meaningful error is thrown in cat() #330

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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