44const importer = require ( './../src' ) . importer
55const exporter = require ( './../src' ) . exporter
66
7+ const chai = require ( 'chai' )
8+ chai . use ( require ( 'dirty-chai' ) )
9+ const expect = chai . expect
710const mh = require ( 'multihashes' )
8- const expect = require ( 'chai' ) . expect
911const BlockService = require ( 'ipfs-block-service' )
1012const IPLDResolver = require ( 'ipld-resolver' )
1113const pull = require ( 'pull-stream' )
1214const pushable = require ( 'pull-pushable' )
1315const whilst = require ( 'async/whilst' )
14- const timers = require ( 'timers ' )
16+ const setImmediate = require ( 'async/setImmediate ' )
1517const leftPad = require ( 'left-pad' )
1618
1719module . 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 ( '/' )
0 commit comments