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

Commit ff17689

Browse files
author
Alan Shaw
committed
test: add tests for disallowed input
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
1 parent 332cefb commit ff17689

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

js/src/files/add.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,26 @@ module.exports = (createCommon, options) => {
120120
})
121121
})
122122

123+
it('should not be able to add a string', (done) => {
124+
const data = `TEST${Date.now()}`
125+
126+
ipfs.files.add(data, (err) => {
127+
expect(err).to.exist()
128+
expect(err.message).to.contain('invalid input')
129+
done()
130+
})
131+
})
132+
133+
it('should not be able to add a non-Buffer TypedArray', (done) => {
134+
const data = Uint8Array.from([Date.now()])
135+
136+
ipfs.files.add(data, (err) => {
137+
expect(err).to.exist()
138+
expect(err.message).to.contain('invalid input')
139+
done()
140+
})
141+
})
142+
123143
it('should add readable stream', (done) => {
124144
const expectedCid = 'QmVv4Wz46JaZJeH5PMV4LGbRiiMKEmszPYY3g6fjGnVXBS'
125145

0 commit comments

Comments
 (0)