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

Commit

Permalink
test: add tests for disallowed input
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
  • Loading branch information
Alan Shaw committed Nov 26, 2018
1 parent 4b2b7fe commit 1ee508f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions js/src/files-regular/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@ module.exports = (createCommon, options) => {
})
})

it('should not be able to add a string', (done) => {
const data = `TEST${Date.now()}`

ipfs.files.add(data, (err) => {
expect(err).to.exist()
expect(err.message).to.contain('invalid input')
done()
})
})

it('should not be able to add a non-Buffer TypedArray', (done) => {
const data = Uint8Array.from([Date.now()])

ipfs.files.add(data, (err) => {
expect(err).to.exist()
expect(err.message).to.contain('invalid input')
done()
})
})

it('should add readable stream', (done) => {
const expectedCid = 'QmVv4Wz46JaZJeH5PMV4LGbRiiMKEmszPYY3g6fjGnVXBS'

Expand Down

0 comments on commit 1ee508f

Please sign in to comment.