File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 568568 totalSize += file . size ;
569569 } ) ;
570570 return totalSize ;
571+ } ,
572+
573+ /**
574+ * Returns the total size uploaded of all files in bytes.
575+ * @function
576+ * @returns {number }
577+ */
578+ sizeUploaded : function ( ) {
579+ var size = 0 ;
580+ each ( this . files , function ( file ) {
581+ size += file . sizeUploaded ( ) ;
582+ } ) ;
583+ return size ;
584+ } ,
585+
586+ /**
587+ * Returns remaining time to upload all files in seconds. Accuracy is based on average speed.
588+ * @function
589+ * @returns {number }
590+ */
591+ timeRemaining : function ( ) {
592+ var time = 0 ;
593+ each ( this . files , function ( file ) {
594+ time += file . timeRemaining ( ) ;
595+ } ) ;
596+ return time ;
571597 }
572598 } ;
573599
Original file line number Diff line number Diff line change @@ -5,7 +5,11 @@ describe('setup', function() {
55 var flow ;
66
77 beforeEach ( function ( ) {
8- flow = new Flow ( ) ;
8+ flow = new Flow ( {
9+ generateUniqueIdentifier : function ( file ) {
10+ return file . size ;
11+ }
12+ } ) ;
913 } ) ;
1014
1115 it ( 'should be supported' , function ( ) {
@@ -31,11 +35,20 @@ describe('setup', function() {
3135 } ) ;
3236
3337 it ( 'test methods' , function ( ) {
34- expect ( flow . getSize ( ) ) . toBe ( 0 ) ;
3538 expect ( flow . getFromUniqueIdentifier ( '' ) ) . toBe ( false ) ;
3639 expect ( flow . progress ( ) ) . toBe ( 0 ) ;
3740 expect ( flow . isUploading ( ) ) . toBe ( false ) ;
3841 expect ( flow . uploadNextChunk ( ) ) . toBe ( false ) ;
42+ expect ( flow . timeRemaining ( ) ) . toBe ( 0 ) ;
43+ expect ( flow . sizeUploaded ( ) ) . toBe ( 0 ) ;
44+ } ) ;
45+
46+ it ( 'test getSize' , function ( ) {
47+ expect ( flow . getSize ( ) ) . toBe ( 0 ) ;
48+ flow . addFile ( new Blob ( [ '1234' ] ) ) ;
49+ expect ( flow . getSize ( ) ) . toBe ( 4 ) ;
50+ flow . addFile ( new Blob ( [ '123' ] ) ) ;
51+ expect ( flow . getSize ( ) ) . toBe ( 7 ) ;
3952 } ) ;
4053
4154 describe ( 'assignBrowse' , function ( ) {
You can’t perform that action at this time.
0 commit comments