mirror of https://gitee.com/bigwinds/arangodb
lots of tests , started dashboardView test
This commit is contained in:
parent
cac63cb9e7
commit
47433edfb1
|
@ -15,8 +15,7 @@
|
|||
alreadyCalledDetailChart: [],
|
||||
|
||||
events: {
|
||||
"click .dashboard-chart": "showDetail",
|
||||
"click #backToCluster": "returnToClusterView"
|
||||
"click .dashboard-chart": "showDetail"
|
||||
},
|
||||
|
||||
tendencies: {
|
||||
|
@ -90,7 +89,6 @@
|
|||
$('#modal-dialog').on('hidden', function () {
|
||||
self.hidden();
|
||||
});
|
||||
//$('.modal-body').css({"max-height": "100%" });
|
||||
$('#modal-dialog').toggleClass("modal-chart-detail", true);
|
||||
options.height = $('.modal-chart-detail').height() * 0.7;
|
||||
options.width = $('.modal-chart-detail').width() * 0.84;
|
||||
|
@ -579,11 +577,6 @@
|
|||
this.updateTendencies();
|
||||
}
|
||||
this.startUpdating();
|
||||
},
|
||||
|
||||
|
||||
returnToClusterView: function () {
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -255,6 +255,7 @@
|
|||
"test/specs/views/graphViewSpec.js",
|
||||
"test/specs/views/documentsViewSpec.js",
|
||||
"test/specs/views/documentViewSpec.js",
|
||||
"test/specs/views/dashboardViewSpec.js",
|
||||
"test/specs/views/graphManagementViewSpec.js",
|
||||
"test/specs/views/newLogsViewSpec.js",
|
||||
"test/specs/views/notificationViewSpec.js",
|
||||
|
|
|
@ -1,65 +1,184 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global describe, it, expect, jasmine, spyOn, beforeEach*/
|
||||
/*global describe, isCoordinator, versionHelper, window, it, expect, jasmine, spyOn, beforeEach*/
|
||||
/*global $, d3, arangoHelper*/
|
||||
|
||||
|
||||
describe("Arango Helper", function() {
|
||||
"use strict";
|
||||
describe("Arango Helper", function () {
|
||||
"use strict";
|
||||
|
||||
describe("Checking collection types converter", function() {
|
||||
describe("Checking collection types converter", function () {
|
||||
|
||||
var ajaxCB;
|
||||
var ajaxCB;
|
||||
|
||||
beforeEach(function () {
|
||||
ajaxCB = function (url, opts) {
|
||||
if (url === "cluster/amICoordinator") {
|
||||
expect(opts.async).toEqual(false);
|
||||
opts.success(true);
|
||||
} else if (url instanceof Object) {
|
||||
opts = url;
|
||||
if (opts.url === "/_api/database/current") {
|
||||
expect(opts.type).toEqual("GET");
|
||||
expect(opts.cache).toEqual(false);
|
||||
expect(opts.async).toEqual(false);
|
||||
expect(opts.contentType).toEqual("application/json");
|
||||
expect(opts.processData).toEqual(false);
|
||||
opts.success({result: {name: "blub"}});
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
spyOn($, "ajax").andCallFake(function (url, opts) {
|
||||
ajaxCB(url, opts);
|
||||
});
|
||||
});
|
||||
|
||||
it("if blank collection name", function () {
|
||||
var myObject = {},
|
||||
dummy;
|
||||
myObject.name = "";
|
||||
dummy = arangoHelper.collectionType(myObject);
|
||||
expect(dummy).toBe("-");
|
||||
});
|
||||
|
||||
it("if type document", function () {
|
||||
var myObject = {},
|
||||
dummy;
|
||||
myObject.type = 2;
|
||||
myObject.name = "testCollection";
|
||||
dummy = arangoHelper.collectionType(myObject);
|
||||
expect(dummy).toBe("document");
|
||||
});
|
||||
|
||||
it("if type edge", function () {
|
||||
var myObject = {},
|
||||
dummy;
|
||||
myObject.type = 3;
|
||||
myObject.name = "testCollection";
|
||||
dummy = arangoHelper.collectionType(myObject);
|
||||
expect(dummy).toBe("edge");
|
||||
});
|
||||
|
||||
it("if type unknown", function () {
|
||||
var myObject = {},
|
||||
dummy;
|
||||
myObject.type = Math.random();
|
||||
myObject.name = "testCollection";
|
||||
dummy = arangoHelper.collectionType(myObject);
|
||||
expect(dummy).toBe("unknown");
|
||||
});
|
||||
|
||||
it("is coordinatoor", function () {
|
||||
var res;
|
||||
res = isCoordinator();
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
|
||||
it("versionHelper_toString", function () {
|
||||
var res;
|
||||
res = versionHelper.toString({
|
||||
major: 2,
|
||||
minor: 0,
|
||||
patch: 1
|
||||
});
|
||||
expect(res).toEqual("2.0.1");
|
||||
});
|
||||
|
||||
it("currentDatabase with success", function () {
|
||||
var res;
|
||||
res = arangoHelper.currentDatabase();
|
||||
expect(res).toEqual("blub");
|
||||
});
|
||||
it("currentDatabase with error", function () {
|
||||
var res;
|
||||
ajaxCB = function (opts) {
|
||||
if (opts.url === "/_api/database/current") {
|
||||
expect(opts.type).toEqual("GET");
|
||||
expect(opts.cache).toEqual(false);
|
||||
expect(opts.async).toEqual(false);
|
||||
expect(opts.contentType).toEqual("application/json");
|
||||
expect(opts.processData).toEqual(false);
|
||||
opts.error({result: {name: "blub"}});
|
||||
}
|
||||
};
|
||||
res = arangoHelper.currentDatabase();
|
||||
expect(res).toEqual(false);
|
||||
});
|
||||
|
||||
it("databaseAllowed with success", function () {
|
||||
var res;
|
||||
spyOn(arangoHelper, "currentDatabase").andReturn("blub");
|
||||
ajaxCB = function (opts) {
|
||||
expect(opts.url).toEqual("/_db/blub/_api/database/");
|
||||
expect(opts.type).toEqual("GET");
|
||||
expect(opts.cache).toEqual(false);
|
||||
expect(opts.async).toEqual(false);
|
||||
expect(opts.contentType).toEqual("application/json");
|
||||
expect(opts.processData).toEqual(false);
|
||||
opts.success();
|
||||
};
|
||||
res = arangoHelper.databaseAllowed();
|
||||
expect(res).toEqual(true);
|
||||
});
|
||||
it("databaseAllowed with error", function () {
|
||||
var res;
|
||||
spyOn(arangoHelper, "currentDatabase").andReturn("blub");
|
||||
ajaxCB = function (opts) {
|
||||
expect(opts.url).toEqual("/_db/blub/_api/database/");
|
||||
expect(opts.type).toEqual("GET");
|
||||
expect(opts.cache).toEqual(false);
|
||||
expect(opts.async).toEqual(false);
|
||||
expect(opts.contentType).toEqual("application/json");
|
||||
expect(opts.processData).toEqual(false);
|
||||
opts.error();
|
||||
};
|
||||
res = arangoHelper.databaseAllowed();
|
||||
expect(res).toEqual(false);
|
||||
});
|
||||
|
||||
it("arangoNotification", function () {
|
||||
var res, notificationList = {
|
||||
add: function () {
|
||||
}
|
||||
};
|
||||
window.App = {
|
||||
notificationList: notificationList
|
||||
};
|
||||
spyOn(notificationList, "add");
|
||||
arangoHelper.arangoNotification("bla", "blub");
|
||||
expect(notificationList.add).toHaveBeenCalledWith({title: "bla", content: "blub"});
|
||||
arangoHelper.arangoError("bla", "blub");
|
||||
expect(notificationList.add).toHaveBeenCalledWith({title: "bla", content: "blub"});
|
||||
});
|
||||
|
||||
it("randomToken", function () {
|
||||
expect(arangoHelper.getRandomToken()).not.toEqual(undefined);
|
||||
});
|
||||
|
||||
it("collectionApiType", function () {
|
||||
var adsDummy = {
|
||||
getCollectionInfo: function () {
|
||||
return {type: 3};
|
||||
}
|
||||
}, adsDummy2 = {
|
||||
getCollectionInfo: function () {
|
||||
return {type: 2};
|
||||
}
|
||||
};
|
||||
arangoHelper.arangoDocumentStore = adsDummy;
|
||||
expect(arangoHelper.collectionApiType("blub", true)).toEqual("edge");
|
||||
arangoHelper.arangoDocumentStore = adsDummy2;
|
||||
expect(arangoHelper.collectionApiType("blub", true)).toEqual("document");
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
ajaxCB = function() {
|
||||
|
||||
};
|
||||
spyOn($, "ajax").andCallFake(function(opts) {
|
||||
ajaxCB(opts);
|
||||
});
|
||||
});
|
||||
|
||||
it("if blank collection name", function() {
|
||||
var myObject = {},
|
||||
dummy;
|
||||
myObject.name = "";
|
||||
dummy = arangoHelper.collectionType(myObject);
|
||||
expect(dummy).toBe("-");
|
||||
describe("checking html escaping", function () {
|
||||
var input = "<&>\"'",
|
||||
expected = "<&>"'";
|
||||
expect(arangoHelper.escapeHtml(input)).toEqual(expected);
|
||||
});
|
||||
|
||||
it("if type document", function() {
|
||||
var myObject = {},
|
||||
dummy;
|
||||
myObject.type = 2;
|
||||
myObject.name = "testCollection";
|
||||
dummy = arangoHelper.collectionType(myObject);
|
||||
expect(dummy).toBe("document");
|
||||
});
|
||||
|
||||
it("if type edge", function() {
|
||||
var myObject = {},
|
||||
dummy;
|
||||
myObject.type = 3;
|
||||
myObject.name = "testCollection";
|
||||
dummy = arangoHelper.collectionType(myObject);
|
||||
expect(dummy).toBe("edge");
|
||||
});
|
||||
|
||||
it("if type unknown", function() {
|
||||
var myObject = {},
|
||||
dummy;
|
||||
myObject.type = Math.random();
|
||||
myObject.name = "testCollection";
|
||||
dummy = arangoHelper.collectionType(myObject);
|
||||
expect(dummy).toBe("unknown");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("checking html escaping", function() {
|
||||
var input = "<&>\"'",
|
||||
expected = "<&>"'";
|
||||
expect(arangoHelper.escapeHtml(input)).toEqual(expected);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/
|
||||
/*global describe, beforeEach, afterEach, Backbone, it, spyOn, expect*/
|
||||
/*global describe, jasmine, beforeEach, afterEach, Backbone, it, spyOn, expect*/
|
||||
/*global $*/
|
||||
|
||||
(function () {
|
||||
|
@ -39,7 +39,7 @@
|
|||
c : {
|
||||
x : 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
expect(col.mergeObjects(o1, o2, ["b", "c"])).toEqual(
|
||||
|
@ -68,7 +68,7 @@
|
|||
b : {
|
||||
x : 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
expect(col.mergeObjects(o1, o2)).toEqual(
|
||||
|
@ -178,7 +178,8 @@
|
|||
},
|
||||
requests: {
|
||||
header: "Requests",
|
||||
labels: ["datetime", "GET", "PUT", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "OTHER"],
|
||||
labels: ["datetime", "GET", "PUT", "POST", "DELETE",
|
||||
"PATCH", "HEAD", "OPTIONS", "OTHER"],
|
||||
stackedGraph: true,
|
||||
div: "requestsChart"
|
||||
},
|
||||
|
@ -187,20 +188,31 @@
|
|||
}
|
||||
}
|
||||
);
|
||||
expect(col.figureDependedOptions.clusterAverageRequestTime.axes.y.axisLabelFormatter(0)).toEqual(0);
|
||||
expect(col.figureDependedOptions.clusterAverageRequestTime.axes.y.axisLabelFormatter(3.4567)).toEqual(3.46);
|
||||
expect(col.figureDependedOptions.clusterAverageRequestTime.axes.y.valueFormatter(3.4567)).toEqual(3.46);
|
||||
expect(col.figureDependedOptions.clusterAverageRequestTime.axes.y.
|
||||
axisLabelFormatter(0)).toEqual(0);
|
||||
expect(col.figureDependedOptions.clusterAverageRequestTime.axes.y.
|
||||
axisLabelFormatter(3.4567)).toEqual(3.46);
|
||||
expect(col.figureDependedOptions.clusterAverageRequestTime.axes.y.
|
||||
valueFormatter(3.4567)).toEqual(3.46);
|
||||
|
||||
expect(col.figureDependedOptions.systemUserTime.axes.y.axisLabelFormatter(0)).toEqual(0);
|
||||
expect(col.figureDependedOptions.systemUserTime.axes.y.axisLabelFormatter(3.4567)).toEqual(3.46);
|
||||
expect(col.figureDependedOptions.systemUserTime.axes.y.valueFormatter(3.4567)).toEqual(3.46);
|
||||
expect(col.figureDependedOptions.systemUserTime.axes.y.
|
||||
axisLabelFormatter(0)).toEqual(0);
|
||||
expect(col.figureDependedOptions.systemUserTime.axes.y.
|
||||
axisLabelFormatter(3.4567)).toEqual(3.46);
|
||||
expect(col.figureDependedOptions.systemUserTime.axes.y.
|
||||
valueFormatter(3.4567)).toEqual(3.46);
|
||||
|
||||
expect(col.figureDependedOptions.totalTime.axes.y.axisLabelFormatter(0)).toEqual(0);
|
||||
expect(col.figureDependedOptions.totalTime.axes.y.axisLabelFormatter(3.4567)).toEqual(3.46);
|
||||
expect(col.figureDependedOptions.totalTime.axes.y.valueFormatter(3.4567)).toEqual(3.46);
|
||||
expect(col.figureDependedOptions.totalTime.axes.y.
|
||||
axisLabelFormatter(0)).toEqual(0);
|
||||
expect(col.figureDependedOptions.totalTime.axes.y.
|
||||
axisLabelFormatter(3.4567)).toEqual(3.46);
|
||||
expect(col.figureDependedOptions.totalTime.axes.y.
|
||||
valueFormatter(3.4567)).toEqual(3.46);
|
||||
|
||||
expect(col.figureDependedOptions.residentSize.axes.y.axisLabelFormatter(3.4567)).toEqual("346%");
|
||||
expect(col.figureDependedOptions.residentSize.axes.y.valueFormatter(3.4567)).toEqual("346%");
|
||||
expect(col.figureDependedOptions.residentSize.axes.y.
|
||||
axisLabelFormatter(3.4567)).toEqual("346%");
|
||||
expect(col.figureDependedOptions.residentSize.axes.y.
|
||||
valueFormatter(3.4567)).toEqual("346%");
|
||||
|
||||
});
|
||||
|
||||
|
@ -256,10 +268,12 @@
|
|||
});
|
||||
expect(res.div).toEqual("systemUserTimeChart");
|
||||
expect(res.header).toEqual("System and User Time");
|
||||
expect(res.labels).toEqual(["datetime", "System Time", "User Time"]);
|
||||
expect(res.labels).toEqual(["datetime",
|
||||
"System Time", "User Time"]);
|
||||
expect(res.labelsDiv ).toEqual(null);
|
||||
expect(res.legend ).toEqual("always");
|
||||
expect(res.axes.x.valueFormatter(-1)).toEqual(col.xAxisFormat(-1));
|
||||
expect(res.axes.x.valueFormatter(-1)).toEqual(
|
||||
col.xAxisFormat(-1));
|
||||
});
|
||||
|
||||
|
||||
|
@ -288,7 +302,8 @@
|
|||
expect(res.labelsKMG2 ).toEqual(false);
|
||||
expect(res.div).toEqual("pageFaultsChart");
|
||||
expect(res.header).toEqual("Page Faults");
|
||||
expect(res.labels).toEqual(["datetime", "Major Page Faults", "Minor Page Faults"]);
|
||||
expect(res.labels).toEqual(["datetime", "Major Page Faults",
|
||||
"Minor Page Faults"]);
|
||||
expect(res.legend ).toEqual("always");
|
||||
expect(res.visibility).toEqual([true, true]);
|
||||
});
|
||||
|
|
|
@ -2,234 +2,247 @@
|
|||
/*global describe, beforeEach, afterEach, it, spyOn, expect, jasmine*/
|
||||
/*global $, arangoHelper*/
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
describe("Arango Collection Model", function() {
|
||||
describe("Arango Collection Model", function () {
|
||||
|
||||
var myCollection;
|
||||
var myCollection;
|
||||
|
||||
beforeEach(function() {
|
||||
myCollection = new window.arangoCollectionModel();
|
||||
beforeEach(function () {
|
||||
myCollection = new window.arangoCollectionModel();
|
||||
});
|
||||
|
||||
it("verifies urlRoot", function () {
|
||||
expect(myCollection.urlRoot).toEqual('/_api/collection');
|
||||
});
|
||||
|
||||
it("verifies defaults", function () {
|
||||
expect(myCollection.get('id')).toEqual('');
|
||||
expect(myCollection.get('name')).toEqual('');
|
||||
expect(myCollection.get('status')).toEqual('');
|
||||
expect(myCollection.get('type')).toEqual('');
|
||||
expect(myCollection.get('isSystem')).toBeFalsy();
|
||||
expect(myCollection.get('picture')).toEqual('');
|
||||
});
|
||||
|
||||
it("verifies set defaults", function () {
|
||||
var name = 'blub',
|
||||
status = 'active',
|
||||
type = 'myType';
|
||||
myCollection = new window.arangoCollectionModel(
|
||||
{
|
||||
name: name,
|
||||
status: status,
|
||||
type: type
|
||||
}
|
||||
);
|
||||
expect(myCollection.get('id')).toEqual('');
|
||||
expect(myCollection.get('name')).toEqual(name);
|
||||
expect(myCollection.get('status')).toEqual(status);
|
||||
expect(myCollection.get('type')).toEqual(type);
|
||||
expect(myCollection.isSystem).toBeFalsy();
|
||||
expect(myCollection.get('picture')).toEqual('');
|
||||
});
|
||||
|
||||
describe("checking ajax", function () {
|
||||
var url, type, shouldFail, successResult, failResult, id, data;
|
||||
|
||||
beforeEach(function () {
|
||||
id = "4711";
|
||||
successResult = "success";
|
||||
failResult = "fail";
|
||||
myCollection.set('id', id);
|
||||
spyOn($, "ajax").andCallFake(function (opt) {
|
||||
expect(opt.url).toEqual(url);
|
||||
expect(opt.type).toEqual(type);
|
||||
expect(opt.success).toEqual(jasmine.any(Function));
|
||||
expect(opt.error).toEqual(jasmine.any(Function));
|
||||
if (opt.data) {
|
||||
expect(opt.data).toEqual(data);
|
||||
}
|
||||
if (shouldFail) {
|
||||
opt.error(failResult);
|
||||
} else {
|
||||
opt.success(successResult);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("getProperties", function () {
|
||||
|
||||
beforeEach(function () {
|
||||
url = "/_api/collection/" + id + "/properties";
|
||||
type = "GET";
|
||||
});
|
||||
|
||||
it("success", function () {
|
||||
shouldFail = false;
|
||||
expect(myCollection.getProperties()).toEqual(successResult);
|
||||
});
|
||||
|
||||
it("fail", function () {
|
||||
shouldFail = true;
|
||||
expect(myCollection.getProperties()).toEqual(failResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getFigures", function () {
|
||||
|
||||
beforeEach(function () {
|
||||
url = "/_api/collection/" + id + "/figures";
|
||||
type = "GET";
|
||||
});
|
||||
|
||||
it("success", function () {
|
||||
shouldFail = false;
|
||||
expect(myCollection.getFigures()).toEqual(successResult);
|
||||
});
|
||||
|
||||
it("fail", function () {
|
||||
shouldFail = true;
|
||||
expect(myCollection.getFigures()).toEqual(failResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getRevision", function () {
|
||||
|
||||
beforeEach(function () {
|
||||
url = "/_api/collection/" + id + "/revision";
|
||||
type = "GET";
|
||||
});
|
||||
|
||||
it("success", function () {
|
||||
shouldFail = false;
|
||||
expect(myCollection.getRevision()).toEqual(successResult);
|
||||
});
|
||||
|
||||
it("fail", function () {
|
||||
shouldFail = true;
|
||||
expect(myCollection.getRevision()).toEqual(failResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getFigures", function () {
|
||||
|
||||
beforeEach(function () {
|
||||
url = "/_api/index/?collection=" + id;
|
||||
type = "GET";
|
||||
});
|
||||
|
||||
it("success", function () {
|
||||
shouldFail = false;
|
||||
expect(myCollection.getIndex()).toEqual(successResult);
|
||||
});
|
||||
|
||||
it("fail", function () {
|
||||
shouldFail = true;
|
||||
expect(myCollection.getIndex()).toEqual(failResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe("loadCollection", function () {
|
||||
|
||||
beforeEach(function () {
|
||||
url = "/_api/collection/" + id + "/load";
|
||||
type = "PUT";
|
||||
});
|
||||
|
||||
it("success", function () {
|
||||
shouldFail = false;
|
||||
spyOn(arangoHelper, "arangoNotification");
|
||||
myCollection.loadCollection();
|
||||
expect(myCollection.get("status")).toEqual("loaded");
|
||||
});
|
||||
|
||||
it("fail", function () {
|
||||
shouldFail = true;
|
||||
spyOn(arangoHelper, "arangoError");
|
||||
myCollection.loadCollection();
|
||||
expect(arangoHelper.arangoError).toHaveBeenCalledWith("Collection error");
|
||||
});
|
||||
});
|
||||
|
||||
describe("unloadCollection", function () {
|
||||
|
||||
beforeEach(function () {
|
||||
url = "/_api/collection/" + id + "/unload";
|
||||
type = "PUT";
|
||||
});
|
||||
|
||||
it("success", function () {
|
||||
shouldFail = false;
|
||||
spyOn(arangoHelper, "arangoNotification");
|
||||
myCollection.unloadCollection();
|
||||
expect(myCollection.get("status")).toEqual("unloaded");
|
||||
});
|
||||
|
||||
it("fail", function () {
|
||||
shouldFail = true;
|
||||
spyOn(arangoHelper, "arangoError");
|
||||
myCollection.unloadCollection();
|
||||
expect(arangoHelper.arangoError).toHaveBeenCalledWith("Collection error");
|
||||
});
|
||||
});
|
||||
|
||||
describe("renameCollection", function () {
|
||||
|
||||
var name;
|
||||
|
||||
beforeEach(function () {
|
||||
name = "newname";
|
||||
url = "/_api/collection/" + id + "/rename";
|
||||
type = "PUT";
|
||||
data = JSON.stringify({name: name});
|
||||
});
|
||||
|
||||
it("success", function () {
|
||||
shouldFail = false;
|
||||
expect(myCollection.renameCollection(name)).toBeTruthy();
|
||||
expect(myCollection.get("name")).toEqual(name);
|
||||
});
|
||||
|
||||
it("fail", function () {
|
||||
shouldFail = true;
|
||||
expect(myCollection.renameCollection(name)).toBeFalsy();
|
||||
expect(myCollection.get("name")).not.toEqual(name);
|
||||
});
|
||||
|
||||
it("fail with parseable error message", function () {
|
||||
shouldFail = true;
|
||||
failResult = {responseText : '{"errorMessage" : "bla"}'};
|
||||
expect(myCollection.renameCollection(name)).toEqual("bla");
|
||||
expect(myCollection.get("name")).not.toEqual(name);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("changeCollection", function () {
|
||||
var wfs, jns;
|
||||
|
||||
beforeEach(function () {
|
||||
wfs = true;
|
||||
jns = 10 * 100 * 1000;
|
||||
url = "/_api/collection/" + id + "/properties";
|
||||
type = "PUT";
|
||||
data = JSON.stringify({waitForSync: wfs, journalSize: jns});
|
||||
});
|
||||
|
||||
it("success", function () {
|
||||
shouldFail = false;
|
||||
expect(myCollection.changeCollection(wfs, jns)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("fail", function () {
|
||||
shouldFail = true;
|
||||
expect(myCollection.changeCollection(wfs, jns)).toBeFalsy();
|
||||
});
|
||||
it("fail with parseable error message", function () {
|
||||
shouldFail = true;
|
||||
failResult = {responseText : '{"errorMessage" : "bla"}'};
|
||||
expect(myCollection.changeCollection(wfs, jns)).toEqual("bla");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("verifies urlRoot", function() {
|
||||
expect(myCollection.urlRoot).toEqual('/_api/collection');
|
||||
});
|
||||
|
||||
it("verifies defaults", function() {
|
||||
expect(myCollection.get('id')).toEqual('');
|
||||
expect(myCollection.get('name')).toEqual('');
|
||||
expect(myCollection.get('status')).toEqual('');
|
||||
expect(myCollection.get('type')).toEqual('');
|
||||
expect(myCollection.get('isSystem')).toBeFalsy();
|
||||
expect(myCollection.get('picture')).toEqual('');
|
||||
});
|
||||
|
||||
it("verifies set defaults", function() {
|
||||
var name = 'blub',
|
||||
status = 'active',
|
||||
type = 'myType';
|
||||
myCollection = new window.arangoCollectionModel(
|
||||
{
|
||||
name : name,
|
||||
status : status,
|
||||
type : type
|
||||
}
|
||||
);
|
||||
expect(myCollection.get('id')).toEqual('');
|
||||
expect(myCollection.get('name')).toEqual(name);
|
||||
expect(myCollection.get('status')).toEqual(status);
|
||||
expect(myCollection.get('type')).toEqual(type);
|
||||
expect(myCollection.isSystem).toBeFalsy();
|
||||
expect(myCollection.get('picture')).toEqual('');
|
||||
});
|
||||
|
||||
describe("checking ajax", function() {
|
||||
var url, type, shouldFail, successResult, failResult, id, data;
|
||||
|
||||
beforeEach(function() {
|
||||
id = "4711";
|
||||
successResult = "success";
|
||||
failResult = "fail";
|
||||
myCollection.set('id', id);
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.url).toEqual(url);
|
||||
expect(opt.type).toEqual(type);
|
||||
expect(opt.success).toEqual(jasmine.any(Function));
|
||||
expect(opt.error).toEqual(jasmine.any(Function));
|
||||
if (opt.data) {
|
||||
expect(opt.data).toEqual(data);
|
||||
}
|
||||
if (shouldFail) {
|
||||
opt.error(failResult);
|
||||
} else {
|
||||
opt.success(successResult);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("getProperties", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
url = "/_api/collection/" + id + "/properties";
|
||||
type = "GET";
|
||||
});
|
||||
|
||||
it("success", function() {
|
||||
shouldFail = false;
|
||||
expect(myCollection.getProperties()).toEqual(successResult);
|
||||
});
|
||||
|
||||
it("fail", function() {
|
||||
shouldFail = true;
|
||||
expect(myCollection.getProperties()).toEqual(failResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getFigures", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
url = "/_api/collection/" + id + "/figures";
|
||||
type = "GET";
|
||||
});
|
||||
|
||||
it("success", function() {
|
||||
shouldFail = false;
|
||||
expect(myCollection.getFigures()).toEqual(successResult);
|
||||
});
|
||||
|
||||
it("fail", function() {
|
||||
shouldFail = true;
|
||||
expect(myCollection.getFigures()).toEqual(failResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getRevision", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
url = "/_api/collection/" + id + "/revision";
|
||||
type = "GET";
|
||||
});
|
||||
|
||||
it("success", function() {
|
||||
shouldFail = false;
|
||||
expect(myCollection.getRevision()).toEqual(successResult);
|
||||
});
|
||||
|
||||
it("fail", function() {
|
||||
shouldFail = true;
|
||||
expect(myCollection.getRevision()).toEqual(failResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getFigures", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
url = "/_api/index/?collection=" + id;
|
||||
type = "GET";
|
||||
});
|
||||
|
||||
it("success", function() {
|
||||
shouldFail = false;
|
||||
expect(myCollection.getIndex()).toEqual(successResult);
|
||||
});
|
||||
|
||||
it("fail", function() {
|
||||
shouldFail = true;
|
||||
expect(myCollection.getIndex()).toEqual(failResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe("loadCollection", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
url = "/_api/collection/" + id + "/load";
|
||||
type = "PUT";
|
||||
});
|
||||
|
||||
it("success", function() {
|
||||
shouldFail = false;
|
||||
spyOn(arangoHelper, "arangoNotification");
|
||||
myCollection.loadCollection();
|
||||
expect(myCollection.get("status")).toEqual("loaded");
|
||||
});
|
||||
|
||||
it("fail", function() {
|
||||
shouldFail = true;
|
||||
spyOn(arangoHelper, "arangoError");
|
||||
myCollection.loadCollection();
|
||||
expect(arangoHelper.arangoError).toHaveBeenCalledWith("Collection error");
|
||||
});
|
||||
});
|
||||
|
||||
describe("unloadCollection", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
url = "/_api/collection/" + id + "/unload";
|
||||
type = "PUT";
|
||||
});
|
||||
|
||||
it("success", function() {
|
||||
shouldFail = false;
|
||||
spyOn(arangoHelper, "arangoNotification");
|
||||
myCollection.unloadCollection();
|
||||
expect(myCollection.get("status")).toEqual("unloaded");
|
||||
});
|
||||
|
||||
it("fail", function() {
|
||||
shouldFail = true;
|
||||
spyOn(arangoHelper, "arangoError");
|
||||
myCollection.unloadCollection();
|
||||
expect(arangoHelper.arangoError).toHaveBeenCalledWith("Collection error");
|
||||
});
|
||||
});
|
||||
|
||||
describe("renameCollection", function() {
|
||||
|
||||
var name;
|
||||
|
||||
beforeEach(function() {
|
||||
name = "newname";
|
||||
url = "/_api/collection/" + id + "/rename";
|
||||
type = "PUT";
|
||||
data = JSON.stringify({name: name});
|
||||
});
|
||||
|
||||
it("success", function() {
|
||||
shouldFail = false;
|
||||
expect(myCollection.renameCollection(name)).toBeTruthy();
|
||||
expect(myCollection.get("name")).toEqual(name);
|
||||
});
|
||||
|
||||
it("fail", function() {
|
||||
shouldFail = true;
|
||||
expect(myCollection.renameCollection(name)).toBeFalsy();
|
||||
expect(myCollection.get("name")).not.toEqual(name);
|
||||
});
|
||||
});
|
||||
|
||||
describe("changeCollection", function() {
|
||||
var wfs, jns;
|
||||
|
||||
beforeEach(function() {
|
||||
wfs = true;
|
||||
jns = 10 * 100 * 1000;
|
||||
url = "/_api/collection/" + id + "/properties";
|
||||
type = "PUT";
|
||||
data = JSON.stringify({waitForSync: wfs, journalSize: jns});
|
||||
});
|
||||
|
||||
it("success", function() {
|
||||
shouldFail = false;
|
||||
expect(myCollection.changeCollection(wfs, jns)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("fail", function() {
|
||||
shouldFail = true;
|
||||
expect(myCollection.changeCollection(wfs, jns)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -83,10 +83,10 @@
|
|||
done : function(f) {
|
||||
f();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
var result = cp.storeCredentials("name", "pw");
|
||||
expect(cp.fetch).toHaveBeenCalled()
|
||||
expect(cp.fetch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("isSymmetricSetup with asymmetrical setup", function () {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue