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

Commit 01aee29

Browse files
committed
refactor: upgrade to latest standard
1 parent 5ff02c5 commit 01aee29

File tree

11 files changed

+282
-251
lines changed

11 files changed

+282
-251
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"readable-stream": "2.2.6"
4343
},
4444
"devDependencies": {
45-
"aegir": "^11.0.1"
45+
"aegir": "^11.0.1",
46+
"dirty-chai": "^1.2.2"
4647
},
4748
"contributors": [
4849
"David Dias <[email protected]>",

src/block.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
'use strict'
55

6-
const expect = require('chai').expect
6+
const chai = require('chai')
7+
const dirtyChai = require('dirty-chai')
8+
const expect = chai.expect
9+
chai.use(dirtyChai)
710
const Block = require('ipfs-block')
811
const multihash = require('multihashes')
912
const CID = require('cids')
@@ -24,9 +27,9 @@ module.exports = (common) => {
2427
this.timeout(20 * 1000)
2528

2629
common.setup((err, factory) => {
27-
expect(err).to.not.exist
30+
expect(err).to.not.exist()
2831
factory.spawnNode((err, node) => {
29-
expect(err).to.not.exist
32+
expect(err).to.not.exist()
3033
ipfs = node
3134
done()
3235
})
@@ -38,11 +41,11 @@ module.exports = (common) => {
3841
describe('callback API', () => {
3942
it('.put a buffer', (done) => {
4043
const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
41-
const cid = new CID(expectedHash)
44+
// const cid = new CID(expectedHash)
4245
const blob = new Buffer('blorb')
4346

4447
ipfs.block.put(blob, (err, block) => {
45-
expect(err).to.not.exist
48+
expect(err).to.not.exist()
4649
expect(block.data).to.be.eql(blob)
4750
expectKey(block, multihash.fromB58String(expectedHash), done)
4851
})
@@ -54,7 +57,7 @@ module.exports = (common) => {
5457
const blob = new Block(new Buffer('blorb'), cid)
5558

5659
ipfs.block.put(blob, (err, block) => {
57-
expect(err).to.not.exist
60+
expect(err).to.not.exist()
5861
expect(block.data).to.eql(new Buffer('blorb'))
5962
expectKey(block, multihash.fromB58String(expectedHash), done)
6063
})
@@ -65,7 +68,7 @@ module.exports = (common) => {
6568
const blob = new Block(new Buffer('blorb'), new CID(expectedHash))
6669

6770
ipfs.block.put(blob, (err, block) => {
68-
expect(err).to.not.exist
71+
expect(err).to.not.exist()
6972
expect(block.data).to.eql(new Buffer('blorb'))
7073
expectKey(block, multihash.fromB58String(expectedHash), done)
7174
})
@@ -85,7 +88,7 @@ module.exports = (common) => {
8588
const cid = new CID(hash)
8689

8790
ipfs.block.get(cid, (err, block) => {
88-
expect(err).to.not.exist
91+
expect(err).to.not.exist()
8992
expect(block.data).to.eql(new Buffer('blorb'))
9093
expectKey(block, cid.multihash, done)
9194
})
@@ -95,7 +98,7 @@ module.exports = (common) => {
9598
const hash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
9699

97100
ipfs.block.get(hash, (err, block) => {
98-
expect(err).to.not.exist
101+
expect(err).to.not.exist()
99102
expect(block.data).to.eql(new Buffer('blorb'))
100103
expectKey(block, multihash.fromB58String(hash), done)
101104
})
@@ -106,7 +109,7 @@ module.exports = (common) => {
106109
const cid = new CID(hash)
107110

108111
ipfs.block.stat(cid, (err, stats) => {
109-
expect(err).to.not.exist
112+
expect(err).to.not.exist()
110113
expect(stats).to.have.property('key')
111114
expect(stats).to.have.property('size')
112115
done()

src/config.js

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33

44
'use strict'
55

6-
const expect = require('chai').expect
6+
const chai = require('chai')
7+
const dirtyChai = require('dirty-chai')
8+
const expect = chai.expect
9+
chai.use(dirtyChai)
710

811
module.exports = (common) => {
912
describe('.config', () => {
1013
let ipfs
1114

1215
before((done) => {
1316
common.setup((err, factory) => {
14-
expect(err).to.not.exist
17+
expect(err).to.not.exist()
1518
factory.spawnNode((err, node) => {
16-
expect(err).to.not.exist
19+
expect(err).to.not.exist()
1720
ipfs = node
1821
done()
1922
})
@@ -28,59 +31,59 @@ module.exports = (common) => {
2831
describe('.get', () => {
2932
it('retrieve the whole config', (done) => {
3033
ipfs.config.get((err, config) => {
31-
expect(err).to.not.exist
32-
expect(config).to.exist
34+
expect(err).to.not.exist()
35+
expect(config).to.exist()
3336
done()
3437
})
3538
})
3639

3740
it('retrieve a value through a key', (done) => {
3841
ipfs.config.get('Identity.PeerID', (err, peerId) => {
39-
expect(err).to.not.exist
40-
expect(peerId).to.exist
42+
expect(err).to.not.exist()
43+
expect(peerId).to.exist()
4144
done()
4245
})
4346
})
4447

4548
it('retrieve a value through a nested key', (done) => {
4649
ipfs.config.get('Addresses.Swarm', (err, swarmAddrs) => {
47-
expect(err).to.not.exist
48-
expect(swarmAddrs).to.exist
50+
expect(err).to.not.exist()
51+
expect(swarmAddrs).to.exist()
4952
done()
5053
})
5154
})
5255

5356
it('fail on non valid key', (done) => {
5457
ipfs.config.get(1234, (err, peerId) => {
55-
expect(err).to.exist
58+
expect(err).to.exist()
5659
done()
5760
})
5861
})
5962

60-
it('fail on non existent key', (done) => {
63+
it('fail on non exist()ent key', (done) => {
6164
ipfs.config.get('Bananas', (err, peerId) => {
62-
expect(err).to.exist
65+
expect(err).to.exist()
6366
done()
6467
})
6568
})
6669
})
6770
describe('.set', () => {
6871
it('set a new key', (done) => {
6972
ipfs.config.set('Fruit', 'banana', (err) => {
70-
expect(err).to.not.exist
73+
expect(err).to.not.exist()
7174
ipfs.config.get('Fruit', (err, fruit) => {
72-
expect(err).to.not.exist
75+
expect(err).to.not.exist()
7376
expect(fruit).to.equal('banana')
7477
done()
7578
})
7679
})
7780
})
7881

79-
it('set an already existing key', (done) => {
82+
it('set an already exist()ing key', (done) => {
8083
ipfs.config.set('Fruit', 'morango', (err) => {
81-
expect(err).to.not.exist
84+
expect(err).to.not.exist()
8285
ipfs.config.get('Fruit', (err, fruit) => {
83-
expect(err).to.not.exist
86+
expect(err).to.not.exist()
8487
expect(fruit).to.equal('morango')
8588
done()
8689
})
@@ -91,9 +94,9 @@ module.exports = (common) => {
9194
const key = 'API.HTTPHeaders.Access-Control-Allow-Origin'
9295
const val = ['http://example.io']
9396
ipfs.config.set(key, val, function (err) {
94-
expect(err).to.not.exist
97+
expect(err).to.not.exist()
9598
ipfs.config.get(key, function (err, result) {
96-
expect(err).to.not.exist
99+
expect(err).to.not.exist()
97100
expect(result).to.deep.equal(val)
98101
done()
99102
})
@@ -102,14 +105,14 @@ module.exports = (common) => {
102105

103106
it('fail on non valid key', (done) => {
104107
ipfs.config.set(new Buffer('heeey'), '', (err) => {
105-
expect(err).to.exist
108+
expect(err).to.exist()
106109
done()
107110
})
108111
})
109112

110113
it('fail on non valid value', (done) => {
111114
ipfs.config.set('Fruit', new Buffer('abc'), (err) => {
112-
expect(err).to.exist
115+
expect(err).to.exist()
113116
done()
114117
})
115118
})
@@ -125,19 +128,19 @@ module.exports = (common) => {
125128

126129
it('replace the whole config', (done) => {
127130
ipfs.config.replace(config, (err) => {
128-
expect(err).to.not.exist
131+
expect(err).to.not.exist()
129132
ipfs.config.get((err, _config) => {
130-
expect(err).to.not.exist
133+
expect(err).to.not.exist()
131134
expect(_config).to.deep.equal(config)
132135
})
133136
})
134137
})
135138

136139
it('replace to empty config', (done) => {
137140
ipfs.config.replace({}, (err) => {
138-
expect(err).to.not.exist
141+
expect(err).to.not.exist()
139142
ipfs.config.get((err, _config) => {
140-
expect(err).to.not.exist
143+
expect(err).to.not.exist()
141144
expect(_config).to.deep.equal(config)
142145
})
143146
})
@@ -150,7 +153,7 @@ module.exports = (common) => {
150153
it('retrieve the whole config', () => {
151154
return ipfs.config.get()
152155
.then((config) => {
153-
expect(config).to.exist
156+
expect(config).to.exist()
154157
})
155158
})
156159
})

0 commit comments

Comments
 (0)