summaryrefslogtreecommitdiffstats
path: root/core/js/tests
diff options
context:
space:
mode:
authorPatrick Paysant <patrick.paysant@linagora.com>2016-12-07 11:43:44 +0100
committerLukas Reschke <lukas@statuscode.ch>2016-12-19 17:29:20 +0100
commitd4c088cb796f22545f79379c27145ef6285d2d5e (patch)
tree18342dca9cd85cc1da274043b3db1df46c625e29 /core/js/tests
parentec4bca619d7cd57271262928b1fe06d5f8dc3211 (diff)
downloadnextcloud-server-d4c088cb796f22545f79379c27145ef6285d2d5e.tar.gz
nextcloud-server-d4c088cb796f22545f79379c27145ef6285d2d5e.zip
Verify input, add more unit tests
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'core/js/tests')
-rw-r--r--core/js/tests/specs/coreSpec.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index 39060f4e473..370ebc6ba2d 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -593,6 +593,8 @@ describe('Core base tests', function() {
describe('computerFileSize', function() {
it('correctly parses file sizes from a human readable formated string', function() {
var data = [
+ ['125', 125],
+ ['125.25', 125.25],
['0 B', 0],
['125 B', 125],
['125b', 125],
@@ -603,13 +605,20 @@ describe('Core base tests', function() {
['119.2 GB', 127990025421],
['119.2gb', 127990025421],
['116.4 TB', 127983153473126],
- ['116.4tb', 127983153473126],
- ['foobar', null]
+ ['116.4tb', 127983153473126]
];
for (var i = 0; i < data.length; i++) {
expect(OC.Util.computerFileSize(data[i][0])).toEqual(data[i][1]);
}
});
+ it('returns null if the parameter is not a string', function() {
+ expect(OC.Util.computerFileSize(NaN)).toEqual(null);
+ expect(OC.Util.computerFileSize(125)).toEqual(null);
+ });
+ it('returns null if the string is unparsable', function() {
+ expect(OC.Util.computerFileSize('')).toEqual(null);
+ expect(OC.Util.computerFileSize('foobar')).toEqual(null);
+ });
});
describe('stripTime', function() {
it('strips time from dates', function() {