@@ -62,7 +62,7 @@ describe(Upload.name, () => {
62
62
Body : "this-is-a-sample-payload" ,
63
63
} ;
64
64
65
- it ( "correctly exposes the event emitter API" , ( done ) => {
65
+ it ( "correctly exposes the event emitter API" , ( ) => {
66
66
const upload = new Upload ( {
67
67
params,
68
68
client : new S3 ( { } ) ,
@@ -72,11 +72,9 @@ describe(Upload.name, () => {
72
72
expect ( upload . eventNames ) . toBeDefined ( ) ;
73
73
expect ( upload . off ) . toBeDefined ( ) ;
74
74
expect ( upload . on ) . toBeDefined ( ) ;
75
-
76
- done ( ) ;
77
75
} ) ;
78
76
79
- it ( "should upload using PUT when empty buffer" , async ( done ) => {
77
+ it ( "should upload using PUT when empty buffer" , async ( ) => {
80
78
const buffer = Buffer . from ( "" ) ;
81
79
const actionParams = { ...params , Body : buffer } ;
82
80
const upload = new Upload ( {
@@ -101,11 +99,9 @@ describe(Upload.name, () => {
101
99
expect ( completeMultipartMock ) . toHaveBeenCalledTimes ( 0 ) ;
102
100
// no tags were passed.
103
101
expect ( putObjectTaggingMock ) . toHaveBeenCalledTimes ( 0 ) ;
104
-
105
- done ( ) ;
106
102
} ) ;
107
103
108
- it ( "should upload using PUT when empty stream" , async ( done ) => {
104
+ it ( "should upload using PUT when empty stream" , async ( ) => {
109
105
const stream = new Readable ( { } ) ;
110
106
stream . push ( null ) ;
111
107
const actionParams = { ...params , Body : stream } ;
@@ -131,11 +127,9 @@ describe(Upload.name, () => {
131
127
expect ( completeMultipartMock ) . toHaveBeenCalledTimes ( 0 ) ;
132
128
// no tags were passed.
133
129
expect ( putObjectTaggingMock ) . toHaveBeenCalledTimes ( 0 ) ;
134
-
135
- done ( ) ;
136
130
} ) ;
137
131
138
- it ( "should upload using PUT when parts are smaller than one part" , async ( done ) => {
132
+ it ( "should upload using PUT when parts are smaller than one part" , async ( ) => {
139
133
const upload = new Upload ( {
140
134
params,
141
135
client : new S3 ( { } ) ,
@@ -158,11 +152,9 @@ describe(Upload.name, () => {
158
152
expect ( completeMultipartMock ) . toHaveBeenCalledTimes ( 0 ) ;
159
153
// no tags were passed.
160
154
expect ( putObjectTaggingMock ) . toHaveBeenCalledTimes ( 0 ) ;
161
-
162
- done ( ) ;
163
155
} ) ;
164
156
165
- it ( "should upload using PUT when parts are smaller than one part stream" , async ( done ) => {
157
+ it ( "should upload using PUT when parts are smaller than one part stream" , async ( ) => {
166
158
const streamBody = Readable . from (
167
159
( function * ( ) {
168
160
yield params . Body ;
@@ -190,11 +182,9 @@ describe(Upload.name, () => {
190
182
expect ( completeMultipartMock ) . toHaveBeenCalledTimes ( 0 ) ;
191
183
// no tags were passed.
192
184
expect ( putObjectTaggingMock ) . toHaveBeenCalledTimes ( 0 ) ;
193
-
194
- done ( ) ;
195
185
} ) ;
196
186
197
- it ( "should upload using multi-part when parts are larger than part size" , async ( done ) => {
187
+ it ( "should upload using multi-part when parts are larger than part size" , async ( ) => {
198
188
// create a string that's larger than 5MB.
199
189
const partSize = 1024 * 1024 * 5 ;
200
190
const largeBuffer = Buffer . from ( "#" . repeat ( partSize + 10 ) ) ;
@@ -256,10 +246,9 @@ describe(Upload.name, () => {
256
246
expect ( putObjectTaggingMock ) . toHaveBeenCalledTimes ( 0 ) ;
257
247
// put was not called
258
248
expect ( putObjectMock ) . toHaveBeenCalledTimes ( 0 ) ;
259
- done ( ) ;
260
249
} ) ;
261
250
262
- it ( "should upload using multi-part when parts are larger than part size stream" , async ( done ) => {
251
+ it ( "should upload using multi-part when parts are larger than part size stream" , async ( ) => {
263
252
// create a string that's larger than 5MB.
264
253
const largeBuffer = Buffer . from ( "#" . repeat ( DEFAULT_PART_SIZE + 10 ) ) ;
265
254
const firstBuffer = largeBuffer . subarray ( 0 , DEFAULT_PART_SIZE ) ;
@@ -325,10 +314,9 @@ describe(Upload.name, () => {
325
314
expect ( putObjectTaggingMock ) . toHaveBeenCalledTimes ( 0 ) ;
326
315
// put was not called
327
316
expect ( putObjectMock ) . toHaveBeenCalledTimes ( 0 ) ;
328
- done ( ) ;
329
317
} ) ;
330
318
331
- it ( "should add tags to the object if tags have been added PUT" , async ( done ) => {
319
+ it ( "should add tags to the object if tags have been added PUT" , async ( ) => {
332
320
const tags = [
333
321
{
334
322
Key : "k1" ,
@@ -358,11 +346,9 @@ describe(Upload.name, () => {
358
346
TagSet : tags ,
359
347
} ,
360
348
} ) ;
361
-
362
- done ( ) ;
363
349
} ) ;
364
350
365
- it ( "should add tags to the object if tags have been added multi-part" , async ( done ) => {
351
+ it ( "should add tags to the object if tags have been added multi-part" , async ( ) => {
366
352
const largeBuffer = Buffer . from ( "#" . repeat ( DEFAULT_PART_SIZE + 10 ) ) ;
367
353
const actionParams = { ...params , Body : largeBuffer } ;
368
354
const tags = [
@@ -394,44 +380,35 @@ describe(Upload.name, () => {
394
380
TagSet : tags ,
395
381
} ,
396
382
} ) ;
397
-
398
- done ( ) ;
399
383
} ) ;
400
384
401
- it ( "should validate partsize" , async ( done ) => {
385
+ it ( "should validate partsize" , ( ) => {
402
386
try {
403
- const upload = new Upload ( {
387
+ new Upload ( {
404
388
params,
405
389
partSize : 6 ,
406
390
client : new S3 ( { } ) ,
407
391
} ) ;
408
-
409
- //should not get here.
410
- expect ( 1 ) . toEqual ( 0 ) ;
392
+ fail ( ) ;
411
393
} catch ( error ) {
412
394
expect ( error ) . toBeDefined ( ) ;
413
- done ( ) ;
414
395
}
415
396
} ) ;
416
397
417
- it ( "should validate queue size" , ( done ) => {
398
+ it ( "should validate queue size" , ( ) => {
418
399
try {
419
- const upload = new Upload ( {
400
+ new Upload ( {
420
401
params,
421
402
queueSize : - 1 ,
422
403
client : new S3 ( { } ) ,
423
404
} ) ;
424
-
425
- //should not get here.
426
- expect ( 1 ) . toEqual ( 0 ) ;
405
+ fail ( ) ;
427
406
} catch ( error ) {
428
407
expect ( error ) . toBeDefined ( ) ;
429
- done ( ) ;
430
408
}
431
- done ( ) ;
432
409
} ) ;
433
410
434
- it ( "should provide progress updates" , async ( done ) => {
411
+ it ( "should provide progress updates" , async ( ) => {
435
412
const upload = new Upload ( {
436
413
params,
437
414
client : new S3 ( { } ) ,
@@ -445,12 +422,11 @@ describe(Upload.name, () => {
445
422
part : 1 ,
446
423
total : 24 ,
447
424
} ) ;
448
- done ( ) ;
449
425
} ) ;
450
426
await upload . done ( ) ;
451
427
} ) ;
452
428
453
- it ( "should provide progress updates multi-part buffer" , async ( done ) => {
429
+ it ( "should provide progress updates multi-part buffer" , async ( ) => {
454
430
const partSize = 1024 * 1024 * 5 ;
455
431
const largeBuffer = Buffer . from ( "#" . repeat ( partSize + 10 ) ) ;
456
432
const firstBuffer = largeBuffer . subarray ( 0 , partSize ) ;
@@ -480,10 +456,9 @@ describe(Upload.name, () => {
480
456
total : largeBuffer . byteLength ,
481
457
} ) ;
482
458
expect ( received . length ) . toBe ( 2 ) ;
483
- done ( ) ;
484
459
} ) ;
485
460
486
- it ( "should provide progress updates multi-part stream" , async ( done ) => {
461
+ it ( "should provide progress updates multi-part stream" , async ( ) => {
487
462
const partSize = 1024 * 1024 * 5 ;
488
463
const largeBuffer = Buffer . from ( "#" . repeat ( partSize + 10 ) ) ;
489
464
const streamBody = Readable . from (
@@ -517,10 +492,9 @@ describe(Upload.name, () => {
517
492
total : undefined ,
518
493
} ) ;
519
494
expect ( received . length ) . toBe ( 2 ) ;
520
- done ( ) ;
521
495
} ) ;
522
496
523
- it ( "should provide progress updates empty buffer" , async ( done ) => {
497
+ it ( "should provide progress updates empty buffer" , async ( ) => {
524
498
const buffer = Buffer . from ( "" ) ;
525
499
const actionParams = { ...params , Body : buffer } ;
526
500
const upload = new Upload ( {
@@ -541,10 +515,9 @@ describe(Upload.name, () => {
541
515
total : 0 ,
542
516
} ) ;
543
517
expect ( received . length ) . toBe ( 1 ) ;
544
- done ( ) ;
545
518
} ) ;
546
519
547
- it ( "should provide progress updates empty stream" , async ( done ) => {
520
+ it ( "should provide progress updates empty stream" , async ( ) => {
548
521
const stream = Readable . from ( ( function * ( ) { } ) ( ) ) ;
549
522
const actionParams = { ...params , Body : stream } ;
550
523
const upload = new Upload ( {
@@ -565,6 +538,5 @@ describe(Upload.name, () => {
565
538
total : 0 ,
566
539
} ) ;
567
540
expect ( received . length ) . toBe ( 1 ) ;
568
- done ( ) ;
569
541
} ) ;
570
542
} ) ;
0 commit comments