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

Commit 8580168

Browse files
committed
test(files): add test to ensure meaningful error is thrown in cat()
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 [email protected]
1 parent 7ed2b58 commit 8580168

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

js/src/files/cat.js

+11
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ module.exports = (createCommon, options) => {
130130
})
131131
})
132132

133+
it('should error on key/path with invalid encoding', () => {
134+
const invalidCid = '/ipfs/QmUzdHisA7ouM8DM5rVAKursVK7t7tKeqDYGvmaCdJw5jEeesdlfjsldkfjsldkfjsdlkfjskldfj'
135+
136+
return ipfs.files.cat(invalidCid)
137+
.catch((err) => {
138+
expect(err).to.exist()
139+
const errString = err.toString()
140+
expect(err.toString()).to.contain('Error: selected encoding not supported')
141+
})
142+
})
143+
133144
it('should error on unknown path (promised)', () => {
134145
return ipfs.files.cat(fixtures.smallFile.cid + '/does-not-exist')
135146
.catch((err) => {

0 commit comments

Comments
 (0)