mirror of https://gitee.com/bigwinds/arangodb
Improved users collection and added tests
This commit is contained in:
parent
c0a347cdc5
commit
e3ffe8fe8a
|
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@
|
|||
|
||||
|
||||
|
||||
}());
|
||||
}());
|
||||
|
|
Loading…
Reference in New Issue