diff options
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]); + } + }); + }); + }); }); |