summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-02-11 16:52:56 +0100
committerVincent Petry <pvince81@owncloud.com>2014-04-28 14:49:39 +0200
commit9f62059efa869ff677130f06bf1b46be49950515 (patch)
tree260c955913a6a8746645d816feffc933b436b343 /core/js
parentefdf0c4df0012fe03fb3de136ff596af1bb38677 (diff)
downloadnextcloud-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.js3
-rw-r--r--core/js/tests/specs/coreSpec.js17
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]);
+ }
+ });
+ });
+ });
});