From e3ffe8fe8a84d02dbb2181645486cc8d6c7b9eba Mon Sep 17 00:00:00 2001 From: Michael Hackstein Date: Thu, 24 Apr 2014 00:42:55 +0200 Subject: [PATCH] Improved users collection and added tests --- .../aardvark/frontend/js/models/arangoUsers.js | 14 ++------------ .../aardvark/test/specs/models/arangoUsersSpec.js | 15 +++++++++++---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/js/apps/system/aardvark/frontend/js/models/arangoUsers.js b/js/apps/system/aardvark/frontend/js/models/arangoUsers.js index 7408cdb938..224eadc1ac 100644 --- a/js/apps/system/aardvark/frontend/js/models/arangoUsers.js +++ b/js/apps/system/aardvark/frontend/js/models/arangoUsers.js @@ -42,8 +42,6 @@ window.Users = Backbone.Model.extend({ processData: false, success: function(data) { result = data.result; - }, - error: function(data) { } }); return result; @@ -57,11 +55,7 @@ window.Users = Backbone.Model.extend({ url: "/_api/user/" + this.get("user"), data: JSON.stringify({ passwd: passwd }), contentType: "application/json", - processData: false, - success: function(data) { - }, - error: function(data) { - } + processData: false }); }, @@ -73,11 +67,7 @@ window.Users = Backbone.Model.extend({ url: "/_api/user/" + this.get("user"), data: JSON.stringify({"extra": {"name":name, "img":img}}), contentType: "application/json", - processData: false, - success: function(data) { - }, - error: function(data) { - } + processData: false }); } diff --git a/js/apps/system/aardvark/test/specs/models/arangoUsersSpec.js b/js/apps/system/aardvark/test/specs/models/arangoUsersSpec.js index 07481d8c70..6f9a4b3953 100644 --- a/js/apps/system/aardvark/test/specs/models/arangoUsersSpec.js +++ b/js/apps/system/aardvark/test/specs/models/arangoUsersSpec.js @@ -1,5 +1,5 @@ /*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/ -/*global describe, beforeEach, afterEach, it, spyOn, expect*/ +/*global describe, beforeEach, afterEach, it, spyOn, expect, jasmine*/ /*global $*/ (function() { @@ -38,12 +38,19 @@ }); it("verifies checkPassword", function() { - var passwd = 'passwd'; + var passwd = 'passwd', + goodResult = "goodResult", + result = "badResult"; spyOn($, "ajax").andCallFake(function(opt) { expect(opt.url).toEqual("/_api/user/" + user); expect(opt.type).toEqual("POST"); + expect(opt.success).toEqual(jasmine.any(Function)); + opt.success({ + result: goodResult + }); }); - myModel.checkPassword(passwd); + result = myModel.checkPassword(passwd); + expect(result).toEqual(goodResult); }); it("verifies parse/isNew/url", function() { @@ -66,4 +73,4 @@ -}()); \ No newline at end of file +}());