Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

fix: throw error on missing input to add/addAll #3818

Merged
merged 2 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
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 packages/interface-ipfs-core/src/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ module.exports = (factory, options) => {
await expect(ipfs.add(nonValid)).to.eventually.be.rejected()
})

it('should fail when passed undefined input', async () => {
// @ts-expect-error undefined is non valid
await expect(ipfs.add(undefined)).to.eventually.be.rejected()
})

it('should fail when passed null input', async () => {
// @ts-expect-error null is non valid
await expect(ipfs.add(null)).to.eventually.be.rejected()
})

it('should wrap content in a directory', async () => {
const data = { path: 'testfile.txt', content: fixtures.smallFile.data }

Expand Down
4 changes: 2 additions & 2 deletions packages/interface-ipfs-core/src/pubsub/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module.exports = (factory, options) => {

it('should fail with undefined msg', async () => {
const topic = getTopic()
// @ts-ignore invalid parameter
await expect(ipfs.pubsub.publish(topic)).to.eventually.rejectedWith('argument "data" is required')
// @ts-expect-error invalid parameter
await expect(ipfs.pubsub.publish(topic)).to.eventually.be.rejected()
})

it('should publish message from buffer', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const {
// eslint-disable-next-line complexity
module.exports = async function * normaliseInput (input, normaliseContent) {
if (input === null || input === undefined) {
return
throw errCode(new Error(`Unexpected input: ${input}`), 'ERR_UNEXPECTED_INPUT')
}

// String
Expand Down