File tree 2 files changed +41
-2
lines changed
2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 568
568
totalSize += file . size ;
569
569
} ) ;
570
570
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 ;
571
597
}
572
598
} ;
573
599
Original file line number Diff line number Diff line change @@ -5,7 +5,11 @@ describe('setup', function() {
5
5
var flow ;
6
6
7
7
beforeEach ( function ( ) {
8
- flow = new Flow ( ) ;
8
+ flow = new Flow ( {
9
+ generateUniqueIdentifier : function ( file ) {
10
+ return file . size ;
11
+ }
12
+ } ) ;
9
13
} ) ;
10
14
11
15
it ( 'should be supported' , function ( ) {
@@ -31,11 +35,20 @@ describe('setup', function() {
31
35
} ) ;
32
36
33
37
it ( 'test methods' , function ( ) {
34
- expect ( flow . getSize ( ) ) . toBe ( 0 ) ;
35
38
expect ( flow . getFromUniqueIdentifier ( '' ) ) . toBe ( false ) ;
36
39
expect ( flow . progress ( ) ) . toBe ( 0 ) ;
37
40
expect ( flow . isUploading ( ) ) . toBe ( false ) ;
38
41
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 ) ;
39
52
} ) ;
40
53
41
54
describe ( 'assignBrowse' , function ( ) {
You can’t perform that action at this time.
0 commit comments