1
0
Fork 0

Improved users collection and added tests

This commit is contained in:
Michael Hackstein 2014-04-24 00:42:55 +02:00
parent c0a347cdc5
commit e3ffe8fe8a
2 changed files with 13 additions and 16 deletions

View File

@ -42,8 +42,6 @@ window.Users = Backbone.Model.extend({
processData: false, processData: false,
success: function(data) { success: function(data) {
result = data.result; result = data.result;
},
error: function(data) {
} }
}); });
return result; return result;
@ -57,11 +55,7 @@ window.Users = Backbone.Model.extend({
url: "/_api/user/" + this.get("user"), url: "/_api/user/" + this.get("user"),
data: JSON.stringify({ passwd: passwd }), data: JSON.stringify({ passwd: passwd }),
contentType: "application/json", contentType: "application/json",
processData: false, processData: false
success: function(data) {
},
error: function(data) {
}
}); });
}, },
@ -73,11 +67,7 @@ window.Users = Backbone.Model.extend({
url: "/_api/user/" + this.get("user"), url: "/_api/user/" + this.get("user"),
data: JSON.stringify({"extra": {"name":name, "img":img}}), data: JSON.stringify({"extra": {"name":name, "img":img}}),
contentType: "application/json", contentType: "application/json",
processData: false, processData: false
success: function(data) {
},
error: function(data) {
}
}); });
} }

View File

@ -1,5 +1,5 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/ /*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 $*/ /*global $*/
(function() { (function() {
@ -38,12 +38,19 @@
}); });
it("verifies checkPassword", function() { it("verifies checkPassword", function() {
var passwd = 'passwd'; var passwd = 'passwd',
goodResult = "goodResult",
result = "badResult";
spyOn($, "ajax").andCallFake(function(opt) { spyOn($, "ajax").andCallFake(function(opt) {
expect(opt.url).toEqual("/_api/user/" + user); expect(opt.url).toEqual("/_api/user/" + user);
expect(opt.type).toEqual("POST"); 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() { it("verifies parse/isNew/url", function() {