@@ -130,32 +130,10 @@ module.exports = (common) => {
130
130
let progress = 0
131
131
const handler = ( p ) => {
132
132
progCount += 1
133
- progress + = p
133
+ progress = p
134
134
}
135
135
136
- ipfs . files . add ( bigFile , { progress : handler } , ( err , res ) => {
137
- expect ( err ) . to . not . exist ( )
138
- expect ( res ) . to . have . length ( 1 )
139
- const file = res [ 0 ]
140
- expect ( file . hash ) . to . equal ( expectedMultihash )
141
- expect ( file . path ) . to . equal ( file . hash )
142
- expect ( progCount ) . to . equal ( 58 )
143
- expect ( progress ) . to . equal ( bigFile . byteLength )
144
- done ( )
145
- } )
146
- } )
147
-
148
- it ( 'BIG buffer with progress' , ( done ) => {
149
- const expectedMultihash = 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq'
150
-
151
- let progCount = 0
152
- let progress = 0
153
- const handler = ( p ) => {
154
- progCount += 1
155
- progress += p
156
- }
157
-
158
- ipfs . files . add ( bigFile , { progress : handler } , ( err , res ) => {
136
+ ipfs . files . add ( bigFile , { progress : handler } , ( err , res ) => {
159
137
expect ( err ) . to . not . exist ( )
160
138
expect ( res ) . to . have . length ( 1 )
161
139
const file = res [ 0 ]
@@ -242,64 +220,14 @@ module.exports = (common) => {
242
220
progress += p
243
221
}
244
222
245
- ipfs . files . add ( dirs , { progress : handler } , ( err , res ) => {
246
- expect ( err ) . to . not . exist ( )
247
- const root = res [ res . length - 1 ]
248
-
249
- expect ( root . path ) . to . equal ( 'test-folder' )
250
- expect ( root . hash ) . to . equal ( expectedRootMultihash )
251
- expect ( progCount ) . to . equal ( 8 )
252
- expect ( progress ) . to . equal ( total )
253
- done ( )
254
- } )
255
- } )
256
-
257
- it ( 'add a nested dir as array with progress' , ( done ) => {
258
- // Needs https://github.com/ipfs/js-ipfs-api/issues/339 to be fixed
259
- // for js-ipfs-api + go-ipfs
260
- if ( ! isNode ) { return done ( ) }
261
-
262
- const content = ( name ) => ( {
263
- path : `test-folder/${ name } ` ,
264
- content : directoryContent [ name ]
265
- } )
266
-
267
- const emptyDir = ( name ) => ( {
268
- path : `test-folder/${ name } `
269
- } )
270
-
271
- const expectedRootMultihash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
272
-
273
- const dirs = [
274
- content ( 'pp.txt' ) ,
275
- content ( 'holmes.txt' ) ,
276
- content ( 'jungle.txt' ) ,
277
- content ( 'alice.txt' ) ,
278
- emptyDir ( 'empty-folder' ) ,
279
- content ( 'files/hello.txt' ) ,
280
- content ( 'files/ipfs.txt' ) ,
281
- emptyDir ( 'files/empty' )
282
- ]
283
-
284
- const total = dirs . reduce ( ( i , entry ) => {
285
- return i + ( entry . content ? entry . content . length : 0 )
286
- } , 0 )
287
-
288
- let progCount = 0
289
- let progress = 0
290
- const handler = ( p ) => {
291
- progCount += 1
292
- progress += p
293
- }
294
-
295
- ipfs . files . add ( dirs , { progress : handler } , ( err , res ) => {
223
+ ipfs . files . add ( dirs , { progress : handler } , ( err , res ) => {
296
224
expect ( err ) . to . not . exist ( )
297
225
const root = res [ res . length - 1 ]
298
226
299
227
expect ( root . path ) . to . equal ( 'test-folder' )
300
228
expect ( root . hash ) . to . equal ( expectedRootMultihash )
301
229
expect ( progCount ) . to . equal ( 8 )
302
- expect ( progress ) . to . equal ( total )
230
+ expect ( progress ) . to . be . at . least ( total )
303
231
done ( )
304
232
} )
305
233
} )
0 commit comments