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

Commit be96ce2

Browse files
test: extend block coverage
1 parent e8f5b64 commit be96ce2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/api/block.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ module.exports = (send) => {
88
stat: argCommand(send, 'block/stat'),
99
put (file, cb) {
1010
if (Array.isArray(file)) {
11-
return cb(null, new Error('block.put() only accepts 1 file'))
11+
let err = new Error('block.put() only accepts 1 file')
12+
if (typeof cb !== 'function') {
13+
return new Promise((resolve, reject) => reject(err))
14+
}
15+
return cb(err)
1216
}
1317
return send('block/put', null, null, file, cb)
1418
}

test/api/block.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ describe('.block', () => {
88
const blorbKey = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
99
const blorb = Buffer('blorb')
1010

11+
it('returns an error when putting an array of files', () => {
12+
return apiClients.a.block.put([blorb, blorb], (err) => {
13+
expect(err).to.be.an.instanceof(Error)
14+
})
15+
})
16+
1117
it('block.put', (done) => {
1218
apiClients.a.block.put(blorb, (err, res) => {
1319
expect(err).to.not.exist
@@ -40,6 +46,13 @@ describe('.block', () => {
4046
})
4147

4248
describe('promise', () => {
49+
it('returns an error when putting an array of files', () => {
50+
return apiClients.a.block.put([blorb, blorb])
51+
.catch((err) => {
52+
expect(err).to.be.an.instanceof(Error)
53+
})
54+
})
55+
4356
it('block.put', () => {
4457
return apiClients.a.block.put(blorb)
4558
.then((res) => {

0 commit comments

Comments
 (0)