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

Commit 238b205

Browse files
author
Alan Shaw
committed
refactor: return CID instances from block.rm
1 parent d71962c commit 238b205

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/block/rm.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = (common, options) => {
3434

3535
const result = await all(ipfs.block.rm(cid))
3636
expect(result).to.be.an('array').and.to.have.lengthOf(1)
37-
expect(result[0]).to.have.property('hash', cid.toString())
37+
expect(result[0].cid.toString()).equal(cid.toString())
3838
expect(result[0]).to.not.have.property('error')
3939

4040
// did we actually remove the block?
@@ -51,7 +51,7 @@ module.exports = (common, options) => {
5151
const result = await all(ipfs.block.rm(cid.toString()))
5252

5353
expect(result).to.be.an('array').and.to.have.lengthOf(1)
54-
expect(result[0]).to.have.property('hash', cid.toString())
54+
expect(result[0].cid.toString()).to.equal(cid.toString())
5555
expect(result[0]).to.not.have.property('error')
5656
})
5757

@@ -63,7 +63,7 @@ module.exports = (common, options) => {
6363
const result = await all(ipfs.block.rm(cid.buffer))
6464

6565
expect(result).to.be.an('array').and.to.have.lengthOf(1)
66-
expect(result[0]).to.have.property('hash', cid.toString())
66+
expect(result[0].cid.toString()).to.equal(cid.toString())
6767
expect(result[0]).to.not.have.property('error')
6868
})
6969

@@ -88,7 +88,7 @@ module.exports = (common, options) => {
8888
expect(result).to.be.an('array').and.to.have.lengthOf(3)
8989

9090
result.forEach((res, index) => {
91-
expect(res).to.have.property('hash', cids[index].toString())
91+
expect(res.cid.toString()).to.equal(cids[index].toString())
9292
expect(res).to.not.have.property('error')
9393
})
9494
})
@@ -106,7 +106,8 @@ module.exports = (common, options) => {
106106
const result = await all(ipfs.block.rm(cid))
107107

108108
expect(result).to.be.an('array').and.to.have.lengthOf(1)
109-
expect(result[0]).to.have.property('error').and.to.include('block not found')
109+
expect(result[0]).to.have.property('error')
110+
expect(result[0].error.message).to.include('block not found')
110111
})
111112

112113
it('should not error when force removing non-existent blocks', async () => {
@@ -122,7 +123,7 @@ module.exports = (common, options) => {
122123
const result = await all(ipfs.block.rm(cid, { force: true }))
123124

124125
expect(result).to.be.an('array').and.to.have.lengthOf(1)
125-
expect(result[0]).to.have.property('hash', cid.toString())
126+
expect(result[0].cid.toString()).to.equal(cid.toString())
126127
expect(result[0]).to.not.have.property('error')
127128
})
128129

@@ -146,7 +147,8 @@ module.exports = (common, options) => {
146147
const result = await all(ipfs.block.rm(cid))
147148

148149
expect(result).to.be.an('array').and.to.have.lengthOf(1)
149-
expect(result[0]).to.have.property('error').and.to.include('pinned')
150+
expect(result[0]).to.have.property('error')
151+
expect(result[0].error.message).to.include('pinned')
150152
})
151153
})
152154
}

0 commit comments

Comments
 (0)