@@ -145,6 +145,28 @@ module.exports = (common) => {
145
145
} )
146
146
} )
147
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 ) => {
159
+ expect ( err ) . to . not . exist ( )
160
+ expect ( res ) . to . have . length ( 1 )
161
+ const file = res [ 0 ]
162
+ expect ( file . hash ) . to . equal ( expectedMultihash )
163
+ expect ( file . path ) . to . equal ( file . hash )
164
+ expect ( progCount ) . to . equal ( 58 )
165
+ expect ( progress ) . to . equal ( 57792 )
166
+ done ( )
167
+ } )
168
+ } )
169
+
148
170
it ( 'add a nested dir as array' , ( done ) => {
149
171
// Needs https://github.com/ipfs/js-ipfs-api/issues/339 to be fixed
150
172
// for js-ipfs-api + go-ipfs
@@ -232,6 +254,52 @@ module.exports = (common) => {
232
254
} )
233
255
} )
234
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
+ let progCount = 0
285
+ let progress = 0
286
+ const handler = ( p ) => {
287
+ progCount += 1
288
+ progress = p
289
+ }
290
+
291
+ ipfs . files . add ( dirs , { progress : handler } , ( err , res ) => {
292
+ expect ( err ) . to . not . exist ( )
293
+ const root = res [ res . length - 1 ]
294
+
295
+ expect ( root . path ) . to . equal ( 'test-folder' )
296
+ expect ( root . hash ) . to . equal ( expectedRootMultihash )
297
+ expect ( progCount ) . to . equal ( 8 )
298
+ expect ( progress ) . to . equal ( 5 )
299
+ done ( )
300
+ } )
301
+ } )
302
+
235
303
describe ( '.createAddStream' , ( ) => {
236
304
it ( 'stream of valid files and dirs' , ( done ) => {
237
305
const content = ( name ) => ( {
0 commit comments