mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel
This commit is contained in:
commit
ebabd76417
|
@ -182,7 +182,7 @@
|
|||
) {
|
||||
this.currentPage = 1;
|
||||
}
|
||||
if (this.totalPages === 0) {
|
||||
if (this.totalPages === 0 || this.totalPages === undefined) {
|
||||
this.totalPages = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@ window.ArangoUsers = Backbone.Collection.extend({
|
|||
return obj.get("user").toLowerCase();
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
//check cookies / local storage
|
||||
},
|
||||
|
||||
login: function (username, password) {
|
||||
this.activeUser = username;
|
||||
return true;
|
||||
|
|
|
@ -163,7 +163,7 @@
|
|||
"clusterFrontend/js/collections/**",
|
||||
"frontend/js/views/footerView.js",
|
||||
"frontend/js/views/dashboardView.js",
|
||||
"frontend/js/collections/arangoStatisticsCollection.js",
|
||||
"frontend/js/collections/arangoStatisticsCollectionSpec.js",
|
||||
"frontend/js/collections/arangoDocuments.js",
|
||||
"frontend/js/models/arangoDocument.js",
|
||||
"frontend/js/config/dygraphConfig.js",
|
||||
|
|
|
@ -110,11 +110,14 @@
|
|||
"frontend/js/collections/arangoDocument.js",
|
||||
"frontend/js/collections/arangoDatabase.js",
|
||||
"frontend/js/collections/arangoLogs.js",
|
||||
"frontend/js/collections/arangoReplication.js",
|
||||
"frontend/js/collections/arangoUsers.js",
|
||||
"frontend/js/collections/arangoStatisticsCollection.js",
|
||||
"frontend/js/collections/arangoStatisticsDescriptionCollection.js",
|
||||
"frontend/js/collections/arangoUsers.js",
|
||||
"frontend/js/collections/foxxCollection.js",
|
||||
"frontend/js/collections/graphCollection.js",
|
||||
"frontend/js/collections/notificationCollection.js",
|
||||
"clusterFrontend/js/collections/clusterServers.js",
|
||||
"clusterFrontend/js/collections/clusterCoordinators.js",
|
||||
"clusterFrontend/js/collections/clusterDatabases.js",
|
||||
|
@ -216,6 +219,14 @@
|
|||
"test/specs/collections/arangoDatabaseSpec.js",
|
||||
"test/specs/collections/arangoDocumentSpec.js",
|
||||
"test/specs/collections/arangoDocumentsSpec.js",
|
||||
"test/specs/collections/arangoLogsSpec.js",
|
||||
"test/specs/collections/arangoReplicationSpec.js",
|
||||
"test/specs/collections/arangoStatisticsCollectionSpec.js",
|
||||
"test/specs/collections/arangoStatisticsDescriptionCollectionSpec.js",
|
||||
"test/specs/collections/arangoUsersSpec.js",
|
||||
"test/specs/collections/foxxCollectionSpec.js",
|
||||
"test/specs/collections/graphCollectionSpec.js",
|
||||
"test/specs/collections/notificationCollectionSpec.js",
|
||||
|
||||
|
||||
"test/specs/views/editListEntryViewSpec.js",
|
||||
|
|
|
@ -27,7 +27,8 @@ module.exports = function(karma) {
|
|||
|
||||
preprocessors: {
|
||||
'test/karma/files.json': ['html2js'],
|
||||
'frontend/js/**/**.js': ['coverage']
|
||||
'frontend/js/**/**.js': ['coverage'],
|
||||
'clusterFrontend/js/**/**.js': ['coverage']
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Karma configuration
|
||||
// Generated on Thu Jul 04 2013 11:39:34 GMT+0200 (CEST)
|
||||
|
||||
filesJSON = require("./file.json");
|
||||
filesJSON = require("./files.json");
|
||||
|
||||
module.exports = function(karma) {
|
||||
|
||||
|
@ -25,7 +25,8 @@ module.exports = function(karma) {
|
|||
],
|
||||
|
||||
preprocessors: {
|
||||
'frontend/js/**/**.js': ['coverage']
|
||||
'frontend/js/**/**.js': ['coverage'],
|
||||
'clusterFrontend/js/**/**.js': ['coverage']
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
});
|
||||
|
||||
it("should getFirstDocuments", function() {
|
||||
expect(col.currentPage).toEqual(1);
|
||||
expect(col.collectionID).toEqual(1);
|
||||
expect(col.totalPages).toEqual(1);
|
||||
expect(col.documentsPerPage).toEqual(10);
|
||||
expect(col.documentsCount).toEqual(1);
|
||||
expect(col.offset).toEqual(0);
|
||||
col.currentPage = 2;
|
||||
window.location.hash = "a/b/c"
|
||||
col.getFirstDocuments();
|
||||
|
@ -44,7 +50,7 @@
|
|||
expect(window.location.hash).toEqual("#a/b/c/3");
|
||||
});
|
||||
|
||||
it("should getDocuments and succeed", function() {
|
||||
it("should getDocuments starting on first page and succeed", function() {
|
||||
var colid = "12345";
|
||||
var currpage = "0";
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
|
@ -82,6 +88,43 @@
|
|||
expect(window.documentsView.renderPagination).toHaveBeenCalledWith(10);
|
||||
});
|
||||
|
||||
it("should getDocuments starting on undefined page and succeed", function() {
|
||||
var colid = "12345";
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
if (opt.type === "GET") {
|
||||
expect(opt.url).toEqual("/_api/collection/" + colid + "/count");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.processData).toEqual(false);
|
||||
opt.success({count : 100});
|
||||
} else if (opt.type === "POST") {
|
||||
expect(opt.url).toEqual('/_api/cursor');
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.data).toEqual(JSON.stringify({
|
||||
query : "FOR x in @@collection SORT TO_NUMBER(x._key) == 0 " +
|
||||
"? x._key : TO_NUMBER(x._key) LIMIT @offset, @count RETURN x",
|
||||
bindVars : {
|
||||
"@collection" : colid,
|
||||
"offset": 0,
|
||||
"count": 10
|
||||
}
|
||||
}));
|
||||
opt.success({result : [{_id : 1, _rev : 2, _key : 4}, {_id : 2, _rev : 2, _key : 4},
|
||||
{_id : 3, _rev : 2, _key : 4}]
|
||||
});
|
||||
}
|
||||
});
|
||||
spyOn(window.arangoDocumentsStore, "reset");
|
||||
spyOn(window.documentsView, "drawTable");
|
||||
spyOn(window.documentsView, "renderPagination");
|
||||
spyOn(window.documentsView, "initTable");
|
||||
var result = col.getDocuments(colid);
|
||||
expect(window.documentsView.renderPagination).toHaveBeenCalledWith(10);
|
||||
});
|
||||
|
||||
it("should getDocuments with exceeding sort count", function() {
|
||||
var colid = "12345";
|
||||
var currpage = "2";
|
||||
|
@ -157,133 +200,204 @@
|
|||
expect(window.documentsView.initTable).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
getFilteredDocuments: function (colid, currpage, filter, bindValues) {
|
||||
var self = this;
|
||||
this.collectionID = colid;
|
||||
this.currentPage = currpage;
|
||||
this.currentFilterPage = currpage;
|
||||
var filterString;
|
||||
if(filter.length === 0){
|
||||
filterString ="";
|
||||
} else {
|
||||
filterString = ' FILTER' + filter.join(' && ');
|
||||
}
|
||||
|
||||
var sortCount = 10000;
|
||||
|
||||
var sortString = '';
|
||||
if (this.documentsCount <= sortCount) {
|
||||
//sorted
|
||||
sortString = " SORT TO_NUMBER(u._key) == 0 ? u._key : TO_NUMBER(u._key)";
|
||||
}
|
||||
|
||||
var myQueryVal = "FOR u in @@collection" + filterString + sortString +
|
||||
" LIMIT @offset, @count RETURN u";
|
||||
|
||||
this.offset = (this.currentPage - 1) * this.documentsPerPage;
|
||||
|
||||
var myQuery = {
|
||||
query: myQueryVal,
|
||||
bindVars: {
|
||||
"@collection": this.collectionID,
|
||||
"count": this.documentsPerPage,
|
||||
"offset": this.offset
|
||||
},
|
||||
options: {
|
||||
fullCount: true
|
||||
}
|
||||
};
|
||||
|
||||
$.each(bindValues, function(k,v) {
|
||||
myQuery.bindVars[k] = v;
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: 'POST',
|
||||
async: false,
|
||||
url: '/_api/cursor',
|
||||
data: JSON.stringify(myQuery),
|
||||
contentType: "application/json",
|
||||
success: function(data) {
|
||||
self.clearDocuments();
|
||||
self.documentsCount = data.extra.fullCount;
|
||||
self.totalPages = Math.ceil(self.documentsCount / self.documentsPerPage);
|
||||
if (
|
||||
isNaN(this.currentPage)
|
||||
|| this.currentPage === undefined
|
||||
|| this.currentPage < 1
|
||||
) {
|
||||
this.currentPage = 1;
|
||||
}
|
||||
if (this.totalPages === 0) {
|
||||
this.totalPages = 1;
|
||||
}
|
||||
|
||||
this.offset = (this.currentPage - 1) * this.documentsPerPage;
|
||||
if (self.documentsCount !== 0) {
|
||||
$.each(data.result, function(k, v) {
|
||||
window.arangoDocumentsStore.add({
|
||||
"id": v._id,
|
||||
"rev": v._rev,
|
||||
"key": v._key,
|
||||
"content": v
|
||||
});
|
||||
});
|
||||
window.documentsView.drawTable();
|
||||
window.documentsView.renderPagination(self.totalPages, true);
|
||||
}
|
||||
else {
|
||||
window.documentsView.initTable();
|
||||
window.documentsView.drawTable();
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
it("should getDocuments with exceeding sort count", function() {
|
||||
var colid = "12345";
|
||||
var currpage = "2";
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
if (opt.type === "GET") {
|
||||
expect(opt.url).toEqual("/_api/collection/" + colid + "/count");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.processData).toEqual(false);
|
||||
opt.success({count : 100000});
|
||||
} else if (opt.type === "POST") {
|
||||
expect(opt.url).toEqual('/_api/cursor');
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.data).toEqual(JSON.stringify({
|
||||
query : "FOR x in @@collection LIMIT @offset, @count RETURN x",
|
||||
bindVars : {
|
||||
"@collection" : colid,
|
||||
"offset": 10,
|
||||
"count": 10
|
||||
}
|
||||
}));
|
||||
opt.success({result : [{_id : 1, _rev : 2, _key : 4}, {_id : 2, _rev : 2, _key : 4},
|
||||
{_id : 3, _rev : 2, _key : 4}]
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
clearDocuments: function () {
|
||||
window.arangoDocumentsStore.reset();
|
||||
},
|
||||
getStatisticsHistory: function(params) {
|
||||
var self = this;
|
||||
var body = {
|
||||
startDate : params.startDate,
|
||||
endDate : params.endDate,
|
||||
figures : params.figures
|
||||
};
|
||||
var server = params.server;
|
||||
var addAuth = function(){};
|
||||
var url = "";
|
||||
if (server) {
|
||||
url = server.endpoint;
|
||||
url += "/_admin/history";
|
||||
if (server.isDBServer) {
|
||||
url += "?DBserver=" + server.target;
|
||||
}
|
||||
addAuth = server.addAuth;
|
||||
} else {
|
||||
url = "/_admin/history";
|
||||
}
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: 'POST',
|
||||
async: false,
|
||||
url: url,
|
||||
data: JSON.stringify(body),
|
||||
contentType: "application/json",
|
||||
beforeSend: addAuth,
|
||||
success: function(data) {
|
||||
self.history = data.result;
|
||||
},
|
||||
error: function(data) {
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
spyOn(window.arangoDocumentsStore, "reset");
|
||||
spyOn(window.documentsView, "drawTable");
|
||||
spyOn(window.documentsView, "renderPagination");
|
||||
spyOn(window.documentsView, "initTable");
|
||||
var result = col.getDocuments(colid, currpage);
|
||||
expect(window.documentsView.renderPagination).toHaveBeenCalledWith(10000);
|
||||
});
|
||||
|
||||
it("should sorted getFilteredDocuments with empty filter", function() {
|
||||
var colid = "12345";
|
||||
var currpage = "2";
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.type).toEqual("POST");
|
||||
expect(opt.url).toEqual('/_api/cursor');
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.data).toEqual(JSON.stringify({
|
||||
query : "FOR u in @@collection SORT TO_NUMBER(u._key) == 0 ? u._key : TO_NUMBER(u._key)" +
|
||||
" LIMIT @offset, @count RETURN u",
|
||||
bindVars :{
|
||||
"@collection":"12345","count":10,"offset":10
|
||||
},
|
||||
options: {
|
||||
fullCount:true
|
||||
}
|
||||
}));
|
||||
opt.success({result : [{_id : 1, _rev : 2, _key : 4}, {_id : 2, _rev : 2, _key : 4},
|
||||
{_id : 3, _rev : 2, _key : 4}], extra : {fullCount : 10}
|
||||
});
|
||||
});
|
||||
spyOn(window.arangoDocumentsStore, "reset");
|
||||
spyOn(window.arangoDocumentsStore, "add");
|
||||
spyOn(window.documentsView, "drawTable");
|
||||
spyOn(window.documentsView, "renderPagination");
|
||||
spyOn(window.documentsView, "initTable");
|
||||
col.documentsCount = 100;
|
||||
var result = col.getFilteredDocuments(colid, currpage, [], []);
|
||||
expect(window.documentsView.renderPagination).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should sorted getFilteredDocuments with empty filter and empty result", function() {
|
||||
var colid = "12345";
|
||||
var currpage = "2";
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.type).toEqual("POST");
|
||||
expect(opt.url).toEqual('/_api/cursor');
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.data).toEqual(JSON.stringify({
|
||||
query : "FOR u in @@collection SORT TO_NUMBER(u._key) == 0 ? u._key : TO_NUMBER(u._key)" +
|
||||
" LIMIT @offset, @count RETURN u",
|
||||
bindVars :{
|
||||
"@collection":"12345","count":10,"offset":10
|
||||
},
|
||||
options: {
|
||||
fullCount:true
|
||||
}
|
||||
}));
|
||||
opt.success({result : [{_id : 1, _rev : 2, _key : 4}, {_id : 2, _rev : 2, _key : 4},
|
||||
{_id : 3, _rev : 2, _key : 4}], extra : {fullCount : 0}
|
||||
});
|
||||
});
|
||||
spyOn(window.arangoDocumentsStore, "reset");
|
||||
spyOn(window.arangoDocumentsStore, "add");
|
||||
spyOn(window.documentsView, "drawTable");
|
||||
spyOn(window.documentsView, "renderPagination");
|
||||
spyOn(window.documentsView, "initTable");
|
||||
col.documentsCount = 100;
|
||||
var result = col.getFilteredDocuments(colid, currpage, [], []);
|
||||
expect(window.documentsView.initTable).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should sorted getFilteredDocuments with filter", function() {
|
||||
var colid = "12345";
|
||||
var currpage = "2";
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.type).toEqual("POST");
|
||||
expect(opt.url).toEqual('/_api/cursor');
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.data).toEqual(JSON.stringify({
|
||||
query : "FOR u in @@collection FILTER u.NAME = @@name && u.AGE > @age SORT TO_NUMBER(u._key) == 0" +
|
||||
" ? u._key : TO_NUMBER(u._key)" +
|
||||
" LIMIT @offset, @count RETURN u",
|
||||
bindVars: {
|
||||
"@collection":"12345",
|
||||
count:10,
|
||||
offset:10,
|
||||
name: "Heinz",
|
||||
age: 4
|
||||
},
|
||||
options: {
|
||||
fullCount:true
|
||||
}
|
||||
}));
|
||||
opt.success({result : [{_id : 1, _rev : 2, _key : 4}, {_id : 2, _rev : 2, _key : 4},
|
||||
{_id : 3, _rev : 2, _key : 4}], extra : {fullCount : 10}
|
||||
});
|
||||
});
|
||||
spyOn(window.arangoDocumentsStore, "reset");
|
||||
spyOn(window.arangoDocumentsStore, "add");
|
||||
spyOn(window.documentsView, "drawTable");
|
||||
spyOn(window.documentsView, "renderPagination");
|
||||
spyOn(window.documentsView, "initTable");
|
||||
col.documentsCount = 100;
|
||||
var result = col.getFilteredDocuments(colid, currpage, [' u.NAME = @@name', ' u.AGE > @age'],
|
||||
{name: "Heinz", age: 4});
|
||||
expect(window.documentsView.renderPagination).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should getStatisticsHistory", function() {
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.type).toEqual("POST");
|
||||
expect(opt.url).toEqual("/_admin/history");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.beforeSend).toNotBe(undefined),
|
||||
expect(opt.data).toEqual(JSON.stringify({startDate : 15000, endDate :18000, figures: ["bytesSend, totalTime"]}));
|
||||
opt.success({result : [{bytesSend : 1, totalTime : 2, time : 4}, {bytesSend : 2, totalTime : 2, time : 4},
|
||||
{bytesSend : 3, totalTime : 2, time : 4}]
|
||||
});
|
||||
});
|
||||
var result = col.getStatisticsHistory({startDate : 15000, endDate :18000, figures: ["bytesSend, totalTime"]});
|
||||
expect(JSON.stringify(col.history)).toEqual(JSON.stringify([{bytesSend : 1, totalTime : 2, time : 4}, {bytesSend : 2, totalTime : 2, time : 4},
|
||||
{bytesSend : 3, totalTime : 2, time : 4}]));
|
||||
});
|
||||
|
||||
it("should getStatisticsHistory from remote dispatcher and get an error", function() {
|
||||
delete col.history;
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.type).toEqual("POST");
|
||||
expect(opt.url).toEqual("endpoint/_admin/history");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.beforeSend).toNotBe(undefined),
|
||||
expect(opt.data).toEqual(JSON.stringify({startDate : 15000, endDate :18000,
|
||||
figures: ["bytesSend, totalTime"]}));
|
||||
opt.error();
|
||||
});
|
||||
var result = col.getStatisticsHistory({server: {endpoint : "endpoint", isDBServer : false,
|
||||
addAuth : "authKey"},
|
||||
startDate : 15000, endDate :18000, figures: ["bytesSend, totalTime"]});
|
||||
expect(col.history).toEqual(undefined);
|
||||
});
|
||||
|
||||
it("should getStatisticsHistory from remote dbserver and get an error", function() {
|
||||
delete col.history;
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.type).toEqual("POST");
|
||||
expect(opt.url).toEqual("endpoint/_admin/history?DBserver=anotherserver");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
expect(opt.beforeSend).toNotBe(undefined),
|
||||
expect(opt.data).toEqual(JSON.stringify({startDate : 15000, endDate :18000,
|
||||
figures: ["bytesSend, totalTime"]}));
|
||||
opt.error();
|
||||
});
|
||||
var result = col.getStatisticsHistory({server: {endpoint : "endpoint", isDBServer : true,
|
||||
addAuth : "authKey", target : "anotherserver"}, startDate : 15000, endDate :18000,
|
||||
figures: ["bytesSend, totalTime"]});
|
||||
expect(col.history).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, $, arangoLog */
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("ArangoLogs", function() {
|
||||
|
||||
var col;
|
||||
|
||||
beforeEach(function() {
|
||||
col = new window.ArangoLogs();
|
||||
window.arangoLogsStore = new window.ArangoLogs();
|
||||
window.logsView = jasmine.createSpyObj(window.LogsView, ['drawTable']);
|
||||
|
||||
});
|
||||
|
||||
it("should parse", function() {
|
||||
var result = col.parse({
|
||||
level: [3, 2, 3], text : ["bla", "blub", "blaf"], lid : [1, 2, 3], timestamp : [10, 11, 12], totalAmount: 3
|
||||
});
|
||||
expect(col.url).toEqual('/_admin/log?upto=4&size=10&offset=0');
|
||||
expect(col.tables).toEqual(["logTableID", "warnTableID", "infoTableID", "debugTableID", "critTableID"]);
|
||||
expect(result).toEqual([
|
||||
{level : 3, lid: 1, text: "bla", timestamp: 10, totalAmount : 3},
|
||||
{level : 2, lid: 2, text: "blub", timestamp: 11, totalAmount : 3},
|
||||
{level : 3, lid: 3, text: "blaf", timestamp: 12, totalAmount : 3}
|
||||
]);
|
||||
});
|
||||
it("should clearLocalStorage", function() {
|
||||
spyOn(window.arangoLogsStore, "reset");
|
||||
col.clearLocalStorage();
|
||||
expect(window.arangoLogsStore.reset).toHaveBeenCalled();
|
||||
});
|
||||
it("should returnElements", function() {
|
||||
col.returnElements();
|
||||
});
|
||||
it("should fillLocalStorage", function() {
|
||||
spyOn(window.arangoLogsStore, "reset");
|
||||
spyOn(window.arangoLogsStore, "add");
|
||||
|
||||
spyOn($, "getJSON").andCallFake(function(url, callback) {
|
||||
expect(url).toEqual("/_admin/log?upto=4&size=10&offset=0");
|
||||
callback({
|
||||
level: [3, 2, 3], text : ["bla", "blub", "blaf"], lid : [1, 2, 3], timestamp : [10, 11, 12], totalAmount: 3
|
||||
})
|
||||
});
|
||||
col.fillLocalStorage();
|
||||
expect(window.arangoLogsStore.reset).toHaveBeenCalled();
|
||||
expect(window.arangoLogsStore.add).toHaveBeenCalledWith({level : 3, lid: 3, text: "blaf", timestamp: 12, totalAmount : 3});
|
||||
expect(window.logsView.drawTable).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should fillLocalStorage for critical table", function() {
|
||||
spyOn(window.arangoLogsStore, "reset");
|
||||
spyOn(window.arangoLogsStore, "add");
|
||||
|
||||
spyOn($, "getJSON").andCallFake(function(url, callback) {
|
||||
expect(url).toEqual("/_admin/log?level=1&size=10&offset=0");
|
||||
callback({
|
||||
level: [3, 2, 3], text : ["bla", "blub", "blaf"], lid : [1, 2, 3], timestamp : [10, 11, 12], totalAmount: 3
|
||||
})
|
||||
});
|
||||
col.fillLocalStorage("critTableID");
|
||||
expect(window.arangoLogsStore.reset).toHaveBeenCalled();
|
||||
expect(window.arangoLogsStore.add).toHaveBeenCalledWith({level : 3, lid: 3, text: "blaf", timestamp: 12, totalAmount : 3});
|
||||
expect(window.logsView.drawTable).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should fillLocalStorage for warnTable table", function() {
|
||||
spyOn(window.arangoLogsStore, "reset");
|
||||
spyOn(window.arangoLogsStore, "add");
|
||||
|
||||
spyOn($, "getJSON").andCallFake(function(url, callback) {
|
||||
expect(url).toEqual("/_admin/log?level=2&size=10&offset=0");
|
||||
callback({
|
||||
level: [3, 2, 3], text : ["bla", "blub", "blaf"], lid : [1, 2, 3], timestamp : [10, 11, 12], totalAmount: 3
|
||||
})
|
||||
});
|
||||
col.fillLocalStorage("warnTableID");
|
||||
expect(window.arangoLogsStore.reset).toHaveBeenCalled();
|
||||
expect(window.arangoLogsStore.add).toHaveBeenCalledWith({level : 3, lid: 3, text: "blaf", timestamp: 12, totalAmount : 3});
|
||||
expect(window.logsView.drawTable).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should fillLocalStorage for infoTable table", function() {
|
||||
spyOn(window.arangoLogsStore, "reset");
|
||||
spyOn(window.arangoLogsStore, "add");
|
||||
|
||||
spyOn($, "getJSON").andCallFake(function(url, callback) {
|
||||
expect(url).toEqual("/_admin/log?level=3&size=10&offset=0");
|
||||
callback({
|
||||
level: [3, 2, 3], text : ["bla", "blub", "blaf"], lid : [1, 2, 3], timestamp : [10, 11, 12], totalAmount: 3
|
||||
})
|
||||
});
|
||||
col.fillLocalStorage("infoTableID");
|
||||
expect(window.arangoLogsStore.reset).toHaveBeenCalled();
|
||||
expect(window.arangoLogsStore.add).toHaveBeenCalledWith({level : 3, lid: 3, text: "blaf", timestamp: 12, totalAmount : 3});
|
||||
expect(window.logsView.drawTable).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should fillLocalStorage for debugTable table", function() {
|
||||
spyOn(window.arangoLogsStore, "reset");
|
||||
spyOn(window.arangoLogsStore, "add");
|
||||
|
||||
spyOn($, "getJSON").andCallFake(function(url, callback) {
|
||||
expect(url).toEqual("/_admin/log?level=4&size=10&offset=0");
|
||||
callback({
|
||||
level: [3, 2, 3], text : ["bla", "blub", "blaf"], lid : [1, 2, 3], timestamp : [10, 11, 12], totalAmount: 3
|
||||
})
|
||||
});
|
||||
col.fillLocalStorage("debugTableID");
|
||||
expect(window.arangoLogsStore.reset).toHaveBeenCalled();
|
||||
expect(window.arangoLogsStore.add).toHaveBeenCalledWith({level : 3, lid: 3, text: "blaf", timestamp: 12, totalAmount : 3});
|
||||
expect(window.logsView.drawTable).toHaveBeenCalled();
|
||||
});
|
||||
})
|
||||
}());
|
|
@ -0,0 +1,65 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, $, arangoLog */
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("ArangoReplication", function() {
|
||||
|
||||
var col;
|
||||
|
||||
beforeEach(function() {
|
||||
col = new window.ArangoReplication();
|
||||
});
|
||||
|
||||
it("getLogState with success", function() {
|
||||
expect(col.url).toEqual('../api/user');
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.url).toEqual("/_api/replication/logger-state");
|
||||
expect(opt.type).toEqual("GET");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.processData).toEqual(false);
|
||||
opt.success("success");
|
||||
});
|
||||
expect(col.getLogState()).toEqual("success");
|
||||
});
|
||||
it("getLogState with error", function() {
|
||||
expect(col.url).toEqual('../api/user');
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.url).toEqual("/_api/replication/logger-state");
|
||||
expect(opt.type).toEqual("GET");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.processData).toEqual(false);
|
||||
opt.error("error");
|
||||
});
|
||||
expect(col.getLogState()).toEqual("error");
|
||||
});
|
||||
|
||||
it("getApplyState with success", function() {
|
||||
expect(col.url).toEqual('../api/user');
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.url).toEqual("/_api/replication/applier-state");
|
||||
expect(opt.type).toEqual("GET");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.processData).toEqual(false);
|
||||
opt.success("success");
|
||||
});
|
||||
expect(col.getApplyState()).toEqual("success");
|
||||
});
|
||||
it("getApplyState with error", function() {
|
||||
expect(col.url).toEqual('../api/user');
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.url).toEqual("/_api/replication/applier-state");
|
||||
expect(opt.type).toEqual("GET");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.processData).toEqual(false);
|
||||
opt.error("error");
|
||||
});
|
||||
expect(col.getApplyState()).toEqual("error");
|
||||
});
|
||||
})
|
||||
}());
|
|
@ -0,0 +1,20 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, $, arangoLog */
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("StatisticsCollection", function() {
|
||||
|
||||
var col;
|
||||
|
||||
beforeEach(function() {
|
||||
col = new window.StatisticsCollection();
|
||||
});
|
||||
|
||||
it("StatisticsCollection", function() {
|
||||
expect(col.model).toEqual(window.Statistics);
|
||||
expect(col.url).toEqual('/_admin/statistics');
|
||||
});
|
||||
})
|
||||
}());
|
|
@ -0,0 +1,21 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, $, arangoLog */
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("StatisticsDescriptionCollection", function() {
|
||||
|
||||
var col;
|
||||
|
||||
beforeEach(function() {
|
||||
col = new window.StatisticsDescriptionCollection();
|
||||
});
|
||||
|
||||
it("StatisticsDescriptionCollection", function() {
|
||||
expect(col.model).toEqual(window.StatisticsDescription);
|
||||
expect(col.url).toEqual('/_admin/statistics-description');
|
||||
expect(col.parse("ee")).toEqual("ee");
|
||||
});
|
||||
})
|
||||
}());
|
|
@ -0,0 +1,170 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, $, arangoLog */
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("ArangoUsers", function() {
|
||||
|
||||
var col;
|
||||
|
||||
beforeEach(function() {
|
||||
col = new window.ArangoUsers();
|
||||
window.App = jasmine.createSpyObj(window.Router, ["navigate"]);
|
||||
});
|
||||
|
||||
it("comparator", function() {
|
||||
expect(col.model).toEqual(window.Users);
|
||||
expect(col.activeUser).toEqual('');
|
||||
expect(col.activeUserSettings).toEqual({
|
||||
"query" : {},
|
||||
"shell" : {},
|
||||
"testing": true
|
||||
});
|
||||
expect(col.url).toEqual("/_api/user");
|
||||
expect(col.comparator({get : function(val) {return "Herbert"}})).toEqual("herbert");
|
||||
});
|
||||
|
||||
it("login", function() {
|
||||
col.login("user", "pw")
|
||||
expect(col.activeUser).toEqual("user");
|
||||
});
|
||||
it("logout", function() {
|
||||
spyOn(col, "reset");
|
||||
spyOn(window.location, "reload");
|
||||
spyOn($, "ajax").andCallFake(function(state , opt) {
|
||||
expect(state).toEqual("unauthorized");
|
||||
expect(opt).toEqual({async:false});
|
||||
return {
|
||||
error : function (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
col.logout()
|
||||
expect(col.activeUser).toEqual(undefined);
|
||||
expect(col.reset).toHaveBeenCalled();
|
||||
expect(window.App.navigate).toHaveBeenCalledWith("");
|
||||
expect(window.location.reload).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("setUserSettings", function() {
|
||||
col.setUserSettings("bad", true);
|
||||
expect(col.activeUserSettings["identifier"]).toEqual(true);
|
||||
});
|
||||
|
||||
it("loadUserSettings with success", function() {
|
||||
col.activeUserSettings = {
|
||||
"query" : {},
|
||||
"shell" : {},
|
||||
"testing": true
|
||||
};
|
||||
col.activeUser = "heinz";
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.url).toEqual("/_api/user/" + encodeURIComponent(col.activeUser));
|
||||
expect(opt.type).toEqual("GET");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.processData).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
opt.success({extra : {
|
||||
Heinz : "herbert",
|
||||
Heinz2 : "herbert2"
|
||||
}});
|
||||
});
|
||||
col.loadUserSettings();
|
||||
expect(col.activeUserSettings).toEqual({
|
||||
Heinz : "herbert",
|
||||
Heinz2 : "herbert2"
|
||||
});
|
||||
});
|
||||
|
||||
it("loadUserSettings with error", function() {
|
||||
col.activeUserSettings = {
|
||||
"query" : {},
|
||||
"shell" : {},
|
||||
"testing": true
|
||||
};
|
||||
col.activeUser = "heinz";
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.url).toEqual("/_api/user/" + encodeURIComponent(col.activeUser));
|
||||
expect(opt.type).toEqual("GET");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.processData).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
opt.error({extra : {
|
||||
Heinz : "herbert",
|
||||
Heinz2 : "herbert2"
|
||||
}});
|
||||
});
|
||||
col.loadUserSettings();
|
||||
expect(col.activeUserSettings).toEqual({
|
||||
"query" : {},
|
||||
"shell" : {},
|
||||
"testing": true
|
||||
});
|
||||
});
|
||||
it("saveUserSettings with success", function() {
|
||||
col.activeUser = "heinz";
|
||||
col.activeUserSettings = {a : "B"};
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.url).toEqual("/_api/user/" + encodeURIComponent(col.activeUser));
|
||||
expect(opt.type).toEqual("PUT");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.data).toEqual(JSON.stringify({ extra: col.activeUserSettings }));
|
||||
expect(opt.processData).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
opt.success();
|
||||
});
|
||||
col.saveUserSettings();
|
||||
expect($.ajax).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("saveUserSettings with error", function() {
|
||||
col.activeUser = "heinz";
|
||||
col.activeUserSettings = {a : "B"};
|
||||
spyOn($, "ajax").andCallFake(function(opt) {
|
||||
expect(opt.url).toEqual("/_api/user/" + encodeURIComponent(col.activeUser));
|
||||
expect(opt.type).toEqual("PUT");
|
||||
expect(opt.contentType).toEqual("application/json");
|
||||
expect(opt.cache).toEqual(false);
|
||||
expect(opt.data).toEqual(JSON.stringify({ extra: col.activeUserSettings }));
|
||||
expect(opt.processData).toEqual(false);
|
||||
expect(opt.async).toEqual(false);
|
||||
opt.error();
|
||||
});
|
||||
col.saveUserSettings();
|
||||
expect($.ajax).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("parse", function() {
|
||||
expect(col.parse({
|
||||
result : ["a", "b", "c"]
|
||||
})).toEqual(["a", "b", "c"]);
|
||||
});
|
||||
|
||||
it("whoAmI without activeUser", function() {
|
||||
col.activeUserSettings = {a : "B"};
|
||||
spyOn($, "ajax").andCallFake(function(state , opt) {
|
||||
expect(state).toEqual("whoAmI");
|
||||
expect(opt).toEqual({async:false});
|
||||
return {
|
||||
done : function (callback) {
|
||||
callback({name : "heinz"});
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(col.whoAmI()).toEqual("heinz");
|
||||
});
|
||||
|
||||
it("whoAmI with activeUser", function() {
|
||||
col.activeUser = "heinz";
|
||||
expect(col.whoAmI()).toEqual("heinz");
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
}());
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, $, arangoLog */
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("FoxxCollection", function() {
|
||||
|
||||
var col;
|
||||
|
||||
beforeEach(function() {
|
||||
col = new window.FoxxCollection();
|
||||
});
|
||||
|
||||
it("FoxxCollection", function() {
|
||||
expect(col.model).toEqual(window.Foxx);
|
||||
expect(col.url).toEqual("/_admin/aardvark/foxxes");
|
||||
});
|
||||
|
||||
})
|
||||
}());
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, $, arangoLog */
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("GraphCollection", function() {
|
||||
|
||||
var col;
|
||||
|
||||
beforeEach(function() {
|
||||
col = new window.GraphCollection();
|
||||
});
|
||||
|
||||
it("parse", function() {
|
||||
expect(col.model).toEqual(window.Graph);
|
||||
expect(col.comparator).toEqual("_key");
|
||||
expect(col.url).toEqual("/_api/graph");
|
||||
expect(col.parse({error: false, graphs : "blub"})).toEqual("blub");
|
||||
expect(col.parse({error: true, graphs : "blub"})).toEqual(undefined);
|
||||
});
|
||||
|
||||
})
|
||||
}());
|
|
@ -0,0 +1,22 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window, $, arangoLog */
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("NotificationCollection", function() {
|
||||
|
||||
var col;
|
||||
|
||||
beforeEach(function() {
|
||||
col = new window.NotificationCollection();
|
||||
});
|
||||
|
||||
it("NotificationCollection", function() {
|
||||
expect(col.model).toEqual(window.Notification);
|
||||
expect(col.url).toEqual("");
|
||||
});
|
||||
|
||||
})
|
||||
}());
|
||||
|
Loading…
Reference in New Issue