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

Commit 29b2740

Browse files
committed
fix: passing browser tests
1 parent 993f746 commit 29b2740

File tree

7 files changed

+63
-59
lines changed

7 files changed

+63
-59
lines changed

src/importer/dir-flat.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const DAGLink = dagPB.DAGLink
99
const DAGNode = dagPB.DAGNode
1010

1111
class DirFlat {
12-
1312
constructor (props) {
1413
this._children = {}
1514
Object.assign(this, props)
@@ -81,7 +80,6 @@ class DirFlat {
8180
],
8281
callback)
8382
}
84-
8583
}
8684

8785
module.exports = createDirFlat

src/importer/tree-builder.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,3 @@ function createTreeBuilder (ipldResolver, _options) {
215215
function notEmpty (str) {
216216
return Boolean(str)
217217
}
218-

test/browser.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ describe('IPFS data importing tests on the Browser', function () {
4545
require('./test-consumable-buffer')
4646
require('./test-consumable-hash')
4747
require('./test-hamt')
48-
require('./test-exporter')(repo)
4948
require('./test-importer')(repo)
5049
require('./test-importer-flush')(repo)
5150
require('./test-import-export')(repo)

test/test-consumable-hash.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const expect = require('chai').expect
4+
const chai = require('chai')
5+
chai.use(require('dirty-chai'))
6+
const expect = chai.expect
57
const crypto = require('crypto')
68
const whilst = require('async/whilst')
79

@@ -18,15 +20,15 @@ describe('consumable hash', () => {
1820

1921
it('can take a 0 length value', (callback) => {
2022
hash('some value').take(0, (err, result) => {
21-
expect(err).to.not.exist
23+
expect(err).to.not.exist()
2224
expect(result).to.be.eql(0)
2325
callback()
2426
})
2527
})
2628

2729
it('can take a 10 bit value', (callback) => {
2830
hash('some value').take(10, (err, result) => {
29-
expect(err).to.not.exist
31+
expect(err).to.not.exist()
3032
expect(result).to.be.eql(110)
3133
callback()
3234
})
@@ -39,7 +41,7 @@ describe('consumable hash', () => {
3941
() => iter > 0,
4042
(callback) => {
4143
h.take(10, (err, result) => {
42-
expect(err).to.not.exist
44+
expect(err).to.not.exist()
4345
values.push(result)
4446
expect(result).to.be.below(1024)
4547
expect(result).to.be.above(0)
@@ -61,7 +63,7 @@ describe('consumable hash', () => {
6163
() => iter > 0,
6264
(callback) => {
6365
h.take(10, (err, result) => {
64-
expect(err).to.not.exist
66+
expect(err).to.not.exist()
6567
values.push(result)
6668
expect(result).to.be.eql(values.shift())
6769
iter--

test/test-dirbuilder-sharding.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
const importer = require('./../src').importer
55
const exporter = require('./../src').exporter
66

7+
const chai = require('chai')
8+
chai.use(require('dirty-chai'))
9+
const expect = chai.expect
710
const mh = require('multihashes')
8-
const expect = require('chai').expect
911
const BlockService = require('ipfs-block-service')
1012
const IPLDResolver = require('ipld-resolver')
1113
const pull = require('pull-stream')
1214
const pushable = require('pull-pushable')
1315
const whilst = require('async/whilst')
14-
const timers = require('timers')
16+
const setImmediate = require('async/setImmediate')
1517
const leftPad = require('left-pad')
1618

1719
module.exports = (repo) => {
@@ -40,12 +42,12 @@ module.exports = (repo) => {
4042
]),
4143
importer(ipldResolver, options),
4244
pull.collect((err, nodes) => {
43-
expect(err).to.not.exist
45+
expect(err).to.not.exist()
4446
expect(nodes.length).to.be.eql(2)
4547
expect(nodes[0].path).to.be.eql('a/b')
4648
expect(nodes[1].path).to.be.eql('a')
4749
nonShardedHash = nodes[1].multihash
48-
expect(nonShardedHash).to.exist
50+
expect(nonShardedHash).to.exist()
4951
done()
5052
})
5153
)
@@ -65,7 +67,7 @@ module.exports = (repo) => {
6567
]),
6668
importer(ipldResolver, options),
6769
pull.collect((err, nodes) => {
68-
expect(err).to.not.exist
70+
expect(err).to.not.exist()
6971
expect(nodes.length).to.be.eql(2)
7072
expect(nodes[0].path).to.be.eql('a/b')
7173
expect(nodes[1].path).to.be.eql('a')
@@ -81,7 +83,7 @@ module.exports = (repo) => {
8183
pull(
8284
exporter(nonShardedHash, ipldResolver),
8385
pull.collect((err, nodes) => {
84-
expect(err).to.not.exist
86+
expect(err).to.not.exist()
8587
expect(nodes.length).to.be.eql(2)
8688
const expectedHash = mh.toB58String(nonShardedHash)
8789
expect(nodes[0].path).to.be.eql(expectedHash)
@@ -96,7 +98,7 @@ module.exports = (repo) => {
9698
)
9799

98100
function collected (err, content) {
99-
expect(err).to.not.exist
101+
expect(err).to.not.exist()
100102
expect(content.length).to.be.eql(1)
101103
expect(content[0].toString()).to.be.eql('i have the best bytes')
102104
done()
@@ -107,7 +109,7 @@ module.exports = (repo) => {
107109
pull(
108110
exporter(shardedHash, ipldResolver),
109111
pull.collect((err, nodes) => {
110-
expect(err).to.not.exist
112+
expect(err).to.not.exist()
111113
expect(nodes.length).to.be.eql(2)
112114
const expectedHash = mh.toB58String(shardedHash)
113115
expect(nodes[0].path).to.be.eql(expectedHash)
@@ -122,7 +124,7 @@ module.exports = (repo) => {
122124
)
123125

124126
function collected (err, content) {
125-
expect(err).to.not.exist
127+
expect(err).to.not.exist()
126128
expect(content.length).to.be.eql(1)
127129
expect(content[0].toString()).to.be.eql('i have the best bytes')
128130
done()
@@ -140,7 +142,7 @@ module.exports = (repo) => {
140142
push,
141143
importer(ipldResolver),
142144
pull.collect((err, nodes) => {
143-
expect(err).to.not.exist
145+
expect(err).to.not.exist()
144146
expect(nodes.length).to.be.eql(maxDirs + 1)
145147
const last = nodes[nodes.length - 1]
146148
expect(last.path).to.be.eql('big')
@@ -162,10 +164,10 @@ module.exports = (repo) => {
162164
content: pull.values([new Buffer(i.toString())])
163165
}
164166
push.push(pushable)
165-
timers.setTimeout(callback, 1)
167+
setImmediate(callback)
166168
},
167169
(err) => {
168-
expect(err).to.not.exist
170+
expect(err).to.not.exist()
169171
push.end()
170172
}
171173
)
@@ -188,13 +190,13 @@ module.exports = (repo) => {
188190
}
189191

190192
function collected (err, content) {
191-
expect(err).to.not.exist
193+
expect(err).to.not.exist()
192194
entries[node.path] = { content: content.toString() }
193195
callback(null, node)
194196
}
195197
}),
196198
pull.collect((err, nodes) => {
197-
expect(err).to.not.exist
199+
expect(err).to.not.exist()
198200
const paths = Object.keys(entries).sort()
199201
expect(paths.length).to.be.eql(2001)
200202
paths.forEach(eachPath)
@@ -207,8 +209,8 @@ module.exports = (repo) => {
207209
// first dir
208210
expect(path).to.be.eql(mh.toB58String(rootHash))
209211
const entry = entries[path]
210-
expect(entry).to.exist
211-
expect(entry.content).to.not.exist
212+
expect(entry).to.exist()
213+
expect(entry.content).to.not.exist()
212214
return
213215
}
214216
// dir entries
@@ -232,7 +234,7 @@ module.exports = (repo) => {
232234
push,
233235
importer(ipldResolver),
234236
pull.collect((err, nodes) => {
235-
expect(err).to.not.exist
237+
expect(err).to.not.exist()
236238
const last = nodes[nodes.length - 1]
237239
expect(last.path).to.be.eql('big')
238240
rootHash = last.multihash
@@ -265,10 +267,10 @@ module.exports = (repo) => {
265267
i = 0
266268
depth++
267269
}
268-
timers.setTimeout(callback, 1)
270+
setImmediate(callback)
269271
},
270272
(err) => {
271-
expect(err).to.not.exist
273+
expect(err).to.not.exist()
272274
push.end()
273275
}
274276
)
@@ -290,7 +292,7 @@ module.exports = (repo) => {
290292
}
291293

292294
function collected (err, content) {
293-
expect(err).to.not.exist
295+
expect(err).to.not.exist()
294296
entries[node.path] = { content: content.toString() }
295297
callback(null, node)
296298
}
@@ -299,7 +301,7 @@ module.exports = (repo) => {
299301
)
300302

301303
function collected (err, nodes) {
302-
expect(err).to.not.exist
304+
expect(err).to.not.exist()
303305
const paths = Object.keys(entries).sort()
304306
expect(paths.length).to.be.eql(maxDepth * maxDirs + maxDepth)
305307
let index = 0
@@ -314,8 +316,8 @@ module.exports = (repo) => {
314316
expect(path).to.be.eql(mh.toB58String(rootHash))
315317
}
316318
const entry = entries[path]
317-
expect(entry).to.exist
318-
expect(entry.content).to.not.exist
319+
expect(entry).to.exist()
320+
expect(entry.content).to.not.exist()
319321
} else {
320322
// dir entries
321323
const pathElements = path.split('/')

test/test-hamt.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/* eslint-env mocha */
22
'use strict'
33

4+
const chai = require('chai')
5+
chai.use(require('dirty-chai'))
6+
const expect = chai.expect
47
const crypto = require('crypto')
5-
const expect = require('chai').expect
68
const each = require('async/each')
79
const eachSeries = require('async/eachSeries')
810

@@ -28,8 +30,8 @@ describe('HAMT', () => {
2830

2931
it('get unknown key returns undefined', (callback) => {
3032
bucket.get('unknown', (err, result) => {
31-
expect(err).to.not.exist
32-
expect(result).to.be.undefined
33+
expect(err).to.not.exist()
34+
expect(result).to.be.undefined()
3335
callback()
3436
})
3537
})
@@ -40,7 +42,7 @@ describe('HAMT', () => {
4042

4143
it('can get that value', (callback) => {
4244
bucket.get('key', (err, result) => {
43-
expect(err).to.not.exist
45+
expect(err).to.not.exist()
4446
expect(result).to.be.eql('value')
4547
callback()
4648
})
@@ -52,7 +54,7 @@ describe('HAMT', () => {
5254

5355
it('can get that value', (callback) => {
5456
bucket.get('key', (err, result) => {
55-
expect(err).to.not.exist
57+
expect(err).to.not.exist()
5658
expect(result).to.be.eql('a different value')
5759
callback()
5860
})
@@ -68,8 +70,8 @@ describe('HAMT', () => {
6870

6971
it('get deleted key returns undefined', (callback) => {
7072
bucket.get('key', (err, result) => {
71-
expect(err).to.not.exist
72-
expect(result).to.be.undefined
73+
expect(err).to.not.exist()
74+
expect(result).to.be.undefined()
7375
callback()
7476
})
7577
})
@@ -104,19 +106,19 @@ describe('HAMT', () => {
104106
}
105107

106108
bucket.get(head, (err, value) => {
107-
expect(err).to.not.exist
109+
expect(err).to.not.exist()
108110
expect(value).to.be.eql(head)
109111
bucket.del(head, afterDel)
110112
})
111113

112114
function afterDel (err) {
113-
expect(err).to.not.exist
115+
expect(err).to.not.exist()
114116
bucket.get(head, afterGet)
115117
}
116118

117119
function afterGet (err, value) {
118-
expect(err).to.not.exist
119-
expect(value).to.be.undefined
120+
expect(err).to.not.exist()
121+
expect(value).to.be.undefined()
120122

121123
each(
122124
keys,
@@ -128,14 +130,14 @@ describe('HAMT', () => {
128130

129131
function onEachKey (key, callback) {
130132
bucket.get(key, (err, value) => {
131-
expect(err).to.not.exist
133+
expect(err).to.not.exist()
132134
expect(value).to.be.eql(key)
133135
callback()
134136
})
135137
}
136138

137139
function reiterate (err) {
138-
expect(err).to.not.exist
140+
expect(err).to.not.exist()
139141
// break from stack on next iteration
140142
process.nextTick(iterate)
141143
}
@@ -147,7 +149,7 @@ describe('HAMT', () => {
147149

148150
it('can still find sole head', (callback) => {
149151
bucket.get(masterHead, (err, value) => {
150-
expect(err).to.not.exist
152+
expect(err).to.not.exist()
151153
expect(value).to.be.eql(masterHead)
152154
callback()
153155
})
@@ -172,7 +174,7 @@ describe('HAMT', () => {
172174
}
173175

174176
eachSeries(keys, (key, callback) => bucket.put(key, key, callback), (err) => {
175-
expect(err).to.not.exist
177+
expect(err).to.not.exist()
176178
callback()
177179
})
178180
})

0 commit comments

Comments
 (0)