From babe9b6f5443aa1d92881e1fde4c820e3ed2f10e Mon Sep 17 00:00:00 2001 From: Denis Wolf Date: Mon, 28 Oct 2013 02:09:09 +0200 Subject: [PATCH 1/3] valid jshint config with globals for tests only --- tests/.jshintrc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/.jshintrc diff --git a/tests/.jshintrc b/tests/.jshintrc new file mode 100644 index 0000000000..3bc176b7f6 --- /dev/null +++ b/tests/.jshintrc @@ -0,0 +1,9 @@ +{ + "strict" : false, // true: Requires all functions run in ES5 Strict Mode + + // Custom Globals + "globals" : { + "it": false, + "describe": false + } +} \ No newline at end of file From 02e2b53a1d8a4b4bc514a175883a505e00c66f95 Mon Sep 17 00:00:00 2001 From: Denis Wolf Date: Mon, 28 Oct 2013 02:09:57 +0200 Subject: [PATCH 2/3] TESTS: Utils.js: tests for validations, uuid generation --- tests/utils.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/utils.js b/tests/utils.js index 70643802f8..ec88aa24c1 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -8,5 +8,28 @@ describe("Utility Methods", function(){ var username = "John\"'-. Doeäâèéë1234"; assert(utils.isUserNameValid(username), 'invalid username'); }); + it("rejects empty string", function(){ + var username = ""; + assert.ifError(utils.isUserNameValid(username), 'accepted as valid username'); + }); + }); + + describe("email validation", function(){ + it("accepts sample address", function(){ + var email = 'sample@example.com'; + assert(utils.isEmailValid(email), 'invalid email'); + }); + it("rejects empty address", function(){ + var email = ''; + assert.ifError(utils.isEmailValid(email), 'accepted as valid email'); + }); + }); + + describe("UUID generation", function(){ + it("return unique random value every time", function(){ + var uuid1 = utils.generateUUID(), + uuid2 = utils.generateUUID(); + assert.notEqual(uuid1, uuid2, "matches"); + }); }); }); From 81e9c9807f61d14d45a83e1bfbb4f139ce867374 Mon Sep 17 00:00:00 2001 From: Denis Wolf Date: Mon, 28 Oct 2013 02:10:44 +0200 Subject: [PATCH 3/3] utils.js - missing semicolon, strict equality --- public/src/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/src/utils.js b/public/src/utils.js index 9f6a9f3c12..71d695fffa 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -11,7 +11,7 @@ generateUUID: function() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, - v = c == 'x' ? r : (r & 0x3 | 0x8); + v = c === 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); }, @@ -225,4 +225,4 @@ module: { exports: {} } -} : module) \ No newline at end of file +} : module); \ No newline at end of file