diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-02-11 16:52:56 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-04-28 14:49:39 +0200 |
commit | 9f62059efa869ff677130f06bf1b46be49950515 (patch) | |
tree | 260c955913a6a8746645d816feffc933b436b343 /core/js | |
parent | efdf0c4df0012fe03fb3de136ff596af1bb38677 (diff) | |
download | nextcloud-server-9f62059efa869ff677130f06bf1b46be49950515.tar.gz nextcloud-server-9f62059efa869ff677130f06bf1b46be49950515.zip |
Fix file summary to use the whole file list
- moved the summary code into a new class FileSummary
- FileSummary is calculated only once, then updated with add/remove
- added new OC.Util namespace for JS utility functions
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/js.js | 3 | ||||
-rw-r--r-- | core/js/tests/specs/coreSpec.js | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js index 0aa8d12b3d6..325be6cdc53 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1253,6 +1253,9 @@ function relative_modified_date(timestamp) { * @todo Write documentation */ OC.Util = { + // TODO: remove original functions from global namespace + humanFileSize: humanFileSize, + formatDate: formatDate, /** * Returns whether the browser supports SVG * @return {boolean} true if the browser supports SVG, false otherwise diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index ccd9f7a1288..65f768fbc51 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -474,5 +474,22 @@ describe('Core base tests', function() { ); }); }); + describe('Util', function() { + describe('humanFileSize', function() { + it('renders file sizes with the correct unit', function() { + var data = [ + [0, '0 B'], + [125, '125 B'], + [128000, '125 kB'], + [128000000, '122.1 MB'], + [128000000000, '119.2 GB'], + [128000000000000, '116.4 TB'] + ]; + for (var i = 0; i < data.length; i++) { + expect(OC.Util.humanFileSize(data[i][0])).toEqual(data[i][1]); + } + }); + }); + }); }); |