1
0
Fork 0

Created Models and Collections for cluster objects. These return fake data right now, but make wiring to foxx a lot easier

This commit is contained in:
Michael Hackstein 2014-01-18 20:15:20 +01:00
parent 6a002416d2
commit a0cb9d832f
25 changed files with 521 additions and 202 deletions

View File

@ -0,0 +1,31 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterCollections = Backbone.Collection.extend({
model: window.ClusterCollection,
url: "/_admin/aardvark/cluster/Collections",
getList: function() {
return [
{
name: "Documents",
status: "ok"
},
{
name: "Edges",
status: "warning"
},
{
name: "People",
status: "critical"
}
];
}
});
}());

View File

@ -0,0 +1,42 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterCoordinators = Backbone.Collection.extend({
model: window.ClusterCoordinator,
url: "/_admin/aardvark/cluster/Coordinators",
getList: function() {
return [
{
name: "Charly",
url: "tcp://192.168.0.1:1337",
status: "ok"
},
{
name: "Carlos",
url: "tcp://192.168.0.2:1337",
status: "critical"
},
{
name: "Chantalle",
url: "tcp://192.168.0.5:1337",
status: "ok"
}
];
},
getOverview: function() {
// Fake data
return {
plan: 3,
having: 2,
status: "critical"
};
}
});
}());

View File

@ -0,0 +1,30 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterDatabases = Backbone.Collection.extend({
model: window.ClusterDatabase,
url: "/_admin/aardvark/cluster/Databases",
getList: function() {
return [
{
name: "_system",
status: "ok"
},
{
name: "myDatabase",
status: "warning"
},
{
name: "otherDatabase",
status: "critical"
}
];
}
});
}());

View File

@ -0,0 +1,57 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterServers = Backbone.Collection.extend({
model: window.ClusterServer,
url: "/_admin/aardvark/cluster/DBServers",
getList: function() {
return [
{
primary: {
name: "Pavel",
url: "tcp://192.168.0.1:1337",
status: "ok"
},
secondary: {
name: "Sally",
url: "tcp://192.168.1.1:1337",
status: "ok"
}
},
{
primary: {
name: "Pancho",
url: "tcp://192.168.0.2:1337",
status: "ok"
}
},
{
primary: {
name: "Pablo",
url: "tcp://192.168.0.5:1337",
status: "critical"
},
secondary: {
name: "Sandy",
url: "tcp://192.168.1.5:1337",
status: "critical"
}
}
];
},
getOverview: function() {
// Fake data
return {
plan: 3,
having: 3,
status: "warning"
};
}
});
}());

View File

@ -0,0 +1,31 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterShards = Backbone.Collection.extend({
model: window.ClusterShard,
url: "/_admin/aardvark/cluster/Shards",
getList: function() {
return [
{
name: "Shard 1",
status: "ok"
},
{
name: "Shard 2",
status: "warning"
},
{
name: "Shard 3",
status: "critical"
}
];
}
});
}());

View File

@ -0,0 +1,20 @@
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterDatabase = Backbone.Model.extend({
defaults: {
"name": "",
"id": ""
},
idAttribute: "id",
url: function() {
return "/_admin/aardvark/cluster/Collections";
}
});
}());

View File

@ -0,0 +1,19 @@
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterCoordinator = Backbone.Model.extend({
defaults: {
"name": "",
"url": ""
},
idAttribute: "name",
url: function() {
return "/_admin/aardvark/cluster/Coordinators";
}
});
}());

View File

@ -0,0 +1,18 @@
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterDatabase = Backbone.Model.extend({
defaults: {
"name": ""
},
idAttribute: "name",
url: function() {
return "/_admin/aardvark/cluster/Databases";
}
});
}());

View File

@ -0,0 +1,20 @@
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterServer = Backbone.Model.extend({
defaults: {
"name": "",
"url": ""
},
idAttribute: "name",
url: function() {
return "/_admin/aardvark/cluster/DBServers";
}
});
}());

View File

@ -0,0 +1,19 @@
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
/*global window, Backbone */
(function() {
"use strict";
window.ClusterShard = Backbone.Model.extend({
defaults: {
"id": ""
},
idAttribute: "id",
url: function() {
return "/_admin/aardvark/cluster/Shards";
}
});
}());

View File

@ -15,23 +15,9 @@
}, },
initialize: function() { initialize: function() {
this.shardsView = new window.ClusterShardsView(); this.shardsView = new window.ClusterShardsView({
this.fakeData = { collection: new window.ClusterShards()
collections: [ });
{
name: "Documents",
status: "ok"
},
{
name: "Edges",
status: "warning"
},
{
name: "People",
status: "critical"
}
]
};
}, },
loadCollection: function(e) { loadCollection: function(e) {
@ -48,7 +34,7 @@
render: function() { render: function() {
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
collections: this.fakeData.collections collections: this.collection.getList()
})); }));
this.shardsView.unrender(); this.shardsView.unrender();
return this; return this;

View File

@ -11,25 +11,6 @@
template: templateEngine.createTemplate("clusterCoordinatorView.ejs"), template: templateEngine.createTemplate("clusterCoordinatorView.ejs"),
initialize: function() { initialize: function() {
this.fakeData = {
coordinators: [
{
name: "Charly",
url: "tcp://192.168.0.1:1337",
status: "ok"
},
{
name: "Carlos",
url: "tcp://192.168.0.2:1337",
status: "critical"
},
{
name: "Chantalle",
url: "tcp://192.168.0.5:1337",
status: "ok"
}
]
};
}, },
unrender: function() { unrender: function() {
@ -38,7 +19,7 @@
render: function() { render: function() {
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
coordinators: this.fakeData.coordinators coordinators: this.collection.getList()
})); }));
return this; return this;
} }

View File

@ -10,9 +10,17 @@
template: templateEngine.createTemplate("clusterDashboardView.ejs"), template: templateEngine.createTemplate("clusterDashboardView.ejs"),
initialize: function() {
this.dbservers = new window.ClusterServers();
this.coordinators = new window.ClusterCoordinators();
},
render: function(){ render: function(){
$(this.el).html(this.template.render({})); $(this.el).html(this.template.render({}));
this.overView = new window.ClusterOverviewView(); this.overView = new window.ClusterOverviewView({
dbservers: this.dbservers,
coordinators: this.coordinators
});
this.overView.render(); this.overView.render();
return this; return this;
} }

View File

@ -15,23 +15,9 @@
}, },
initialize: function() { initialize: function() {
this.colView = new window.ClusterCollectionView(); this.colView = new window.ClusterCollectionView({
this.fakeData = { collection: new window.ClusterCollections()
databases: [ });
{
name: "_system",
status: "ok"
},
{
name: "myDatabase",
status: "warning"
},
{
name: "otherDatabase",
status: "critical"
}
]
};
}, },
loadDatabase: function(e) { loadDatabase: function(e) {
@ -46,7 +32,7 @@
render: function(){ render: function(){
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
databases: this.fakeData.databases databases: this.collection.getList()
})); }));
this.colView.unrender(); this.colView.unrender();
return this; return this;

View File

@ -16,21 +16,14 @@
}, },
initialize: function() { initialize: function() {
this.fakeData = { this.dbservers = this.options.dbservers;
dbservers: { this.coordinators = this.options.coordinators;
plan: 3, this.serverView = new window.ClusterServerView({
having: 3, collection: this.dbservers
status: "warning" });
}, this.coordinatorView = new window.ClusterCoordinatorView({
coordinators: { collection: this.coordinators
plan: 3, });
having: 2,
status: "critical"
}
};
this.serverView = new window.ClusterServerView();
this.coordinatorView = new window.ClusterCoordinatorView();
}, },
loadDBServers: function() { loadDBServers: function() {
@ -48,8 +41,8 @@
render: function(minify){ render: function(minify){
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
minify: minify, minify: minify,
dbservers: this.fakeData.dbservers, dbservers: this.dbservers.getOverview(),
coordinators: this.fakeData.coordinators coordinators: this.coordinators.getOverview()
})); }));
$(this.el).toggleClass("clusterColumnMax", !minify); $(this.el).toggleClass("clusterColumnMax", !minify);
return this; return this;

View File

@ -15,41 +15,9 @@
}, },
initialize: function() { initialize: function() {
this.dbView = new window.ClusterDatabaseView(); this.dbView = new window.ClusterDatabaseView({
collection: new window.ClusterDatabases()
this.fakeData = [ });
{
primary: {
name: "Pavel",
url: "tcp://192.168.0.1:1337",
status: "ok"
},
secondary: {
name: "Sally",
url: "tcp://192.168.1.1:1337",
status: "ok"
}
},
{
primary: {
name: "Pancho",
url: "tcp://192.168.0.2:1337",
status: "ok"
}
},
{
primary: {
name: "Pablo",
url: "tcp://192.168.0.5:1337",
status: "critical"
},
secondary: {
name: "Sandy",
url: "tcp://192.168.1.5:1337",
status: "critical"
}
}
];
}, },
loadServer: function(e) { loadServer: function(e) {
@ -71,7 +39,7 @@
} }
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
minify: minify, minify: minify,
servers: this.fakeData servers: this.collection.getList()
})); }));
return this; return this;
} }

View File

@ -10,32 +10,13 @@
template: templateEngine.createTemplate("clusterShardsView.ejs"), template: templateEngine.createTemplate("clusterShardsView.ejs"),
initialize: function() {
this.fakeData = {
shards: [
{
name: "Shard 1",
status: "ok"
},
{
name: "Shard 2",
status: "warning"
},
{
name: "Shard 3",
status: "critical"
}
]
};
},
unrender: function() { unrender: function() {
$(this.el).html(""); $(this.el).html("");
}, },
render: function() { render: function() {
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
shards: this.fakeData.shards shards: this.collection.getList()
})); }));
return this; return this;
} }

View File

@ -127,6 +127,11 @@ module.exports = function(karma) {
'frontend/js/models/arangoStatisticsDescription.js', 'frontend/js/models/arangoStatisticsDescription.js',
'frontend/js/models/foxx.js', 'frontend/js/models/foxx.js',
'frontend/js/models/graph.js', 'frontend/js/models/graph.js',
'frontend/js/models/clusterServer.js',
'frontend/js/models/clusterCoordinator.js',
'frontend/js/models/clusterDatabase.js',
'frontend/js/models/clusterCollection.js',
'frontend/js/models/clusterShard.js',
// Collections // Collections
'frontend/js/collections/arangoCollections.js', 'frontend/js/collections/arangoCollections.js',
@ -139,6 +144,11 @@ module.exports = function(karma) {
'frontend/js/collections/arangoStatisticsDescriptionCollection.js', 'frontend/js/collections/arangoStatisticsDescriptionCollection.js',
'frontend/js/collections/foxxCollection.js', 'frontend/js/collections/foxxCollection.js',
'frontend/js/collections/graphCollection.js', 'frontend/js/collections/graphCollection.js',
'frontend/js/collections/clusterServers.js',
'frontend/js/collections/clusterCoordinators.js',
'frontend/js/collections/clusterDatabases.js',
'frontend/js/collections/clusterCollections.js',
'frontend/js/collections/clusterShards.js',
// Views // Views
'frontend/js/views/navigationView.js', 'frontend/js/views/navigationView.js',
@ -184,7 +194,6 @@ module.exports = function(karma) {
//Templates //Templates
{pattern: 'frontend/js/templates/*.ejs', served:true, included:false, watched: true}, {pattern: 'frontend/js/templates/*.ejs', served:true, included:false, watched: true},
// Specs // Specs
// GraphViewer // GraphViewer
'test/specs/graphViewer/specColourMapper/colourMapperSpec.js', 'test/specs/graphViewer/specColourMapper/colourMapperSpec.js',
'test/specs/graphViewer/specWindowObjects/domObserverFactorySpec.js', 'test/specs/graphViewer/specWindowObjects/domObserverFactorySpec.js',

View File

@ -6,7 +6,7 @@
"use strict"; "use strict";
describe("Cluster Collection View", function() { describe("Cluster Collection View", function() {
var view, div, shardsView; var view, div, shardsView, shardCol;
beforeEach(function() { beforeEach(function() {
div = document.createElement("div"); div = document.createElement("div");
@ -16,7 +16,11 @@
render: function() {}, render: function() {},
unrender: function() {} unrender: function() {}
}; };
shardCol = {
__refId: "testId"
};
spyOn(window, "ClusterShardsView").andReturn(shardsView); spyOn(window, "ClusterShardsView").andReturn(shardsView);
spyOn(window, "ClusterShards").andReturn(shardCol);
uiMatchers.define(this); uiMatchers.define(this);
}); });
@ -28,14 +32,17 @@
it("should create a Cluster Server View", function() { it("should create a Cluster Server View", function() {
view = new window.ClusterCollectionView(); view = new window.ClusterCollectionView();
expect(window.ClusterShardsView).toHaveBeenCalled(); expect(window.ClusterShards).toHaveBeenCalled();
expect(window.ClusterShardsView).toHaveBeenCalledWith({
collection: shardCol
});
}); });
}); });
describe("rendering", function() { describe("rendering", function() {
var docs, edges, people, colls, var docs, edges, people, colls, collCol,
checkButtonContent = function(col, cls) { checkButtonContent = function(col, cls) {
var btn = document.getElementById(col.name); var btn = document.getElementById(col.name);
expect(btn).toBeOfClass("btn"); expect(btn).toBeOfClass("btn");
@ -64,10 +71,16 @@
edges, edges,
people people
]; ];
collCol = {
getList: function() {
return colls;
}
};
spyOn(shardsView, "render"); spyOn(shardsView, "render");
spyOn(shardsView, "unrender"); spyOn(shardsView, "unrender");
view = new window.ClusterCollectionView(); view = new window.ClusterCollectionView({
view.fakeData.collections = colls; collection: collCol
});
view.render(); view.render();
}); });

View File

@ -22,6 +22,7 @@
describe("rendering", function() { describe("rendering", function() {
var charly, carlos, chantalle, coordinators, var charly, carlos, chantalle, coordinators,
coordCol,
getTile = function(name) { getTile = function(name) {
return document.getElementById(name); return document.getElementById(name);
}, },
@ -38,7 +39,6 @@
}; };
beforeEach(function() { beforeEach(function() {
view = new window.ClusterCoordinatorView();
charly = { charly = {
name: "Charly", name: "Charly",
url: "tcp://192.168.0.1:1337", url: "tcp://192.168.0.1:1337",
@ -59,7 +59,14 @@
carlos, carlos,
chantalle chantalle
]; ];
view.fakeData.coordinators = coordinators; coordCol = {
getList: function() {
return coordinators;
}
};
view = new window.ClusterCoordinatorView({
collection: coordCol
});
view.render(); view.render();
}); });

View File

@ -22,28 +22,61 @@
document.body.removeChild(div); document.body.removeChild(div);
}); });
describe("rendering", function() { describe("initialisation", function() {
var info;
var servCol, coorCol;
beforeEach(function() { beforeEach(function() {
servCol = {
__id: "servId"
};
coorCol = {
__id: "coorId"
};
spyOn(overview, "render"); spyOn(overview, "render");
spyOn(window, "ClusterServers").andReturn(servCol);
spyOn(window, "ClusterCoordinators").andReturn(coorCol);
view = new window.ClusterDashboardView(); view = new window.ClusterDashboardView();
}); });
it("should create a Cluster Overview View", function() { it("should create the cluster server collection", function() {
expect(window.ClusterOverviewView).not.toHaveBeenCalled(); expect(window.ClusterServers).toHaveBeenCalled();
window.ClusterOverviewView.reset();
view.render();
expect(window.ClusterOverviewView).toHaveBeenCalled();
window.ClusterOverviewView.reset();
view.render();
expect(window.ClusterOverviewView).toHaveBeenCalled();
}); });
it("should render the Cluster Overview", function() { it("should create the cluster coordinators collection", function() {
view.render(); expect(window.ClusterCoordinators).toHaveBeenCalled();
expect(overview.render).toHaveBeenCalled();
}); });
describe("rendering", function() {
var info;
beforeEach(function() {
window.ClusterServers.reset();
window.ClusterCoordinators.reset();
});
it("should create a Cluster Overview View", function() {
expect(window.ClusterOverviewView).not.toHaveBeenCalled();
expect(window.ClusterServers).not.toHaveBeenCalled();
expect(window.ClusterCoordinators).not.toHaveBeenCalled();
window.ClusterOverviewView.reset();
view.render();
expect(window.ClusterOverviewView).toHaveBeenCalled();
expect(window.ClusterServers).not.toHaveBeenCalled();
expect(window.ClusterCoordinators).not.toHaveBeenCalled();
window.ClusterOverviewView.reset();
view.render();
expect(window.ClusterOverviewView).toHaveBeenCalled();
expect(window.ClusterServers).not.toHaveBeenCalled();
expect(window.ClusterCoordinators).not.toHaveBeenCalled();
});
it("should render the Cluster Overview", function() {
view.render();
expect(overview.render).toHaveBeenCalled();
});
});
}); });
}); });

View File

@ -6,7 +6,7 @@
"use strict"; "use strict";
describe("Cluster Database View", function() { describe("Cluster Database View", function() {
var view, div, colView; var view, div, colView, colCol;
beforeEach(function() { beforeEach(function() {
div = document.createElement("div"); div = document.createElement("div");
@ -16,7 +16,11 @@
render: function() {}, render: function() {},
unrender: function() {} unrender: function() {}
}; };
colCol = {
__id: "refId"
};
spyOn(window, "ClusterCollectionView").andReturn(colView); spyOn(window, "ClusterCollectionView").andReturn(colView);
spyOn(window, "ClusterCollections").andReturn(colCol);
uiMatchers.define(this); uiMatchers.define(this);
}); });
@ -27,15 +31,20 @@
describe("initialisation", function() { describe("initialisation", function() {
it("should create a Cluster Collection View", function() { it("should create a Cluster Collection View", function() {
view = new window.ClusterDatabaseView(); view = new window.ClusterDatabaseView({
expect(window.ClusterCollectionView).toHaveBeenCalled(); collection: {}
});
expect(window.ClusterCollections).toHaveBeenCalled();
expect(window.ClusterCollectionView).toHaveBeenCalledWith({
collection: colCol
});
}); });
}); });
describe("rendering", function() { describe("rendering", function() {
var db1, db2, db3, databases, var db1, db2, db3, databases, dbCol,
checkButtonContent = function(db, cls) { checkButtonContent = function(db, cls) {
var btn = document.getElementById(db.name); var btn = document.getElementById(db.name);
expect(btn).toBeOfClass("btn"); expect(btn).toBeOfClass("btn");
@ -66,8 +75,14 @@
db2, db2,
db3 db3
]; ];
view = new window.ClusterDatabaseView(); dbCol = {
view.fakeData.databases = databases; getList: function() {
return databases;
}
};
view = new window.ClusterDatabaseView({
collection: dbCol
});
view.render(); view.render();
}); });

View File

@ -6,7 +6,11 @@
"use strict"; "use strict";
describe("Cluster Overview View", function() { describe("Cluster Overview View", function() {
var view, div, serverView, coordinatorView; var view, div, serverView, coordinatorView,
clusterServers, serverStatus,
serverHaving, serverPlan,
clusterCoordinators, coordinatorStatus,
coordinatorHaving, coordinatorPlan;
beforeEach(function() { beforeEach(function() {
div = document.createElement("div"); div = document.createElement("div");
@ -20,6 +24,30 @@
render: function() {}, render: function() {},
unrender: function() {} unrender: function() {}
}; };
serverStatus = "warning";
serverHaving = 3;
serverPlan = 3;
clusterServers = {
getOverview: function() {
return {
plan: serverPlan,
having: serverHaving,
status: serverStatus
};
}
};
coordinatorStatus = "critical";
coordinatorHaving = 2;
coordinatorPlan = 3;
clusterCoordinators = {
getOverview: function() {
return {
plan: coordinatorPlan,
having: coordinatorHaving,
status: coordinatorStatus
};
}
};
spyOn(window, "ClusterServerView").andReturn(serverView); spyOn(window, "ClusterServerView").andReturn(serverView);
spyOn(window, "ClusterCoordinatorView").andReturn(coordinatorView); spyOn(window, "ClusterCoordinatorView").andReturn(coordinatorView);
uiMatchers.define(this); uiMatchers.define(this);
@ -32,8 +60,23 @@
describe("initialisation", function() { describe("initialisation", function() {
it("should create a Cluster Server View", function() { it("should create a Cluster Server View", function() {
view = new window.ClusterOverviewView(); view = new window.ClusterOverviewView({
expect(window.ClusterServerView).toHaveBeenCalled(); dbservers: clusterServers,
coordinators: clusterCoordinators
});
expect(window.ClusterServerView).toHaveBeenCalledWith({
collection: clusterServers
});
});
it("should create a Cluster Coordinator View", function() {
view = new window.ClusterOverviewView({
dbservers: clusterServers,
coordinators: clusterCoordinators
});
expect(window.ClusterCoordinatorView).toHaveBeenCalledWith({
collection: clusterCoordinators
});
}); });
}); });
@ -86,20 +129,10 @@
spyOn(serverView, "unrender"); spyOn(serverView, "unrender");
spyOn(coordinatorView, "render"); spyOn(coordinatorView, "render");
spyOn(coordinatorView, "unrender"); spyOn(coordinatorView, "unrender");
view = new window.ClusterOverviewView(); view = new window.ClusterOverviewView({
// Fake Data Injection to be removed dbservers: clusterServers,
view.fakeData = { coordinators: clusterCoordinators
dbservers: { });
plan: 3,
having: 3,
status: "warning"
},
coordinators: {
plan: 3,
having: 2,
status: "critical"
}
};
}); });
describe("minified version", function() { describe("minified version", function() {
@ -127,8 +160,8 @@
}; };
it("should render the amounts", function() { it("should render the amounts", function() {
view.fakeData.dbservers.plan = 5; serverPlan = 5;
view.fakeData.dbservers.having = 4; serverHaving = 4;
view.render(true); view.render(true);
var btn = getButton(), var btn = getButton(),
span = btn.firstChild, span = btn.firstChild,
@ -143,21 +176,21 @@
it("should render the status ok", function() { it("should render the status ok", function() {
var status = "ok"; var status = "ok";
view.fakeData.dbservers.status = status; serverStatus = status;
view.render(true); view.render(true);
checkShowStatus(getButton(), status); checkShowStatus(getButton(), status);
}); });
it("should render the status warning", function() { it("should render the status warning", function() {
var status = "warning"; var status = "warning";
view.fakeData.dbservers.status = status; serverStatus = status;
view.render(true); view.render(true);
checkShowStatus(getButton(), status); checkShowStatus(getButton(), status);
}); });
it("should render the status critical", function() { it("should render the status critical", function() {
var status = "critical"; var status = "critical";
view.fakeData.dbservers.status = status; serverStatus = status;
view.render(true); view.render(true);
checkShowStatus(getButton(), status); checkShowStatus(getButton(), status);
}); });
@ -171,8 +204,8 @@
}; };
it("should render the amounts", function() { it("should render the amounts", function() {
view.fakeData.coordinators.plan = 5; coordinatorPlan = 5;
view.fakeData.coordinators.having = 4; coordinatorHaving = 4;
view.render(true); view.render(true);
var btn = getButton(), var btn = getButton(),
span = btn.firstChild, span = btn.firstChild,
@ -187,21 +220,21 @@
it("should render the status ok", function() { it("should render the status ok", function() {
var status = "ok"; var status = "ok";
view.fakeData.coordinators.status = status; coordinatorStatus = status;
view.render(true); view.render(true);
checkShowStatus(getButton(), status); checkShowStatus(getButton(), status);
}); });
it("should render the status warning", function() { it("should render the status warning", function() {
var status = "warning"; var status = "warning";
view.fakeData.coordinators.status = status; coordinatorStatus = status;
view.render(true); view.render(true);
checkShowStatus(getButton(), status); checkShowStatus(getButton(), status);
}); });
it("should render the status critical", function() { it("should render the status critical", function() {
var status = "critical"; var status = "critical";
view.fakeData.coordinators.status = status; coordinatorStatus = status;
view.render(true); view.render(true);
checkShowStatus(getButton(), status); checkShowStatus(getButton(), status);
}); });
@ -233,8 +266,8 @@
}; };
it("should render the tile", function() { it("should render the tile", function() {
view.fakeData.dbservers.plan = 5; serverPlan = 5;
view.fakeData.dbservers.having = 4; serverHaving = 4;
view.render(); view.render();
var tile = getTile(), var tile = getTile(),
headers = $("> h4", $(tile)), headers = $("> h4", $(tile)),
@ -256,21 +289,21 @@
it("should render the status ok", function() { it("should render the status ok", function() {
var status = "ok"; var status = "ok";
view.fakeData.dbservers.status = status; serverStatus = status;
view.render(); view.render();
checkShowStatus(getTile(), status); checkShowStatus(getTile(), status);
}); });
it("should render the status warning", function() { it("should render the status warning", function() {
var status = "warning"; var status = "warning";
view.fakeData.dbservers.status = status; serverStatus = status;
view.render(); view.render();
checkShowStatus(getTile(), status); checkShowStatus(getTile(), status);
}); });
it("should render the status critical", function() { it("should render the status critical", function() {
var status = "critical"; var status = "critical";
view.fakeData.dbservers.status = status; serverStatus = status;
view.render(); view.render();
checkShowStatus(getTile(), status); checkShowStatus(getTile(), status);
}); });
@ -284,8 +317,8 @@
}; };
it("should render the tile", function() { it("should render the tile", function() {
view.fakeData.coordinators.plan = 5; coordinatorPlan = 5;
view.fakeData.coordinators.having = 4; coordinatorHaving = 4;
view.render(); view.render();
var tile = getTile(), var tile = getTile(),
headers = $("> h4", $(tile)), headers = $("> h4", $(tile)),
@ -307,21 +340,21 @@
it("should render the status ok", function() { it("should render the status ok", function() {
var status = "ok"; var status = "ok";
view.fakeData.coordinators.status = status; coordinatorStatus = status;
view.render(); view.render();
checkShowStatus(getTile(), status); checkShowStatus(getTile(), status);
}); });
it("should render the status warning", function() { it("should render the status warning", function() {
var status = "warning"; var status = "warning";
view.fakeData.coordinators.status = status; coordinatorStatus = status;
view.render(); view.render();
checkShowStatus(getTile(), status); checkShowStatus(getTile(), status);
}); });
it("should render the status critical", function() { it("should render the status critical", function() {
var status = "critical"; var status = "critical";
view.fakeData.coordinators.status = status; coordinatorStatus = status;
view.render(); view.render();
checkShowStatus(getTile(), status); checkShowStatus(getTile(), status);
}); });

View File

@ -6,7 +6,7 @@
"use strict"; "use strict";
describe("Cluster Server View", function() { describe("Cluster Server View", function() {
var view, div, dbView; var view, div, dbView, dbCol;
beforeEach(function() { beforeEach(function() {
div = document.createElement("div"); div = document.createElement("div");
@ -16,7 +16,11 @@
render: function() {}, render: function() {},
unrender: function() {} unrender: function() {}
}; };
dbCol = {
__id: "testId"
};
spyOn(window, "ClusterDatabaseView").andReturn(dbView); spyOn(window, "ClusterDatabaseView").andReturn(dbView);
spyOn(window, "ClusterDatabases").andReturn(dbCol);
uiMatchers.define(this); uiMatchers.define(this);
}); });
@ -28,14 +32,17 @@
it("should create a Cluster Database View", function() { it("should create a Cluster Database View", function() {
view = new window.ClusterServerView(); view = new window.ClusterServerView();
expect(window.ClusterDatabaseView).toHaveBeenCalled(); expect(window.ClusterDatabaseView).toHaveBeenCalledWith({
collection: dbCol
});
}); });
}); });
describe("rendering", function() { describe("rendering", function() {
var okPair, noBkp, deadBkp, deadPrim, deadPair, fakeServers, var okPair, noBkp, deadBkp, deadPrim, deadPair,
fakeServers, dbServers,
getTile = function(name) { getTile = function(name) {
return document.getElementById(name); return document.getElementById(name);
}, },
@ -79,7 +86,6 @@
beforeEach(function() { beforeEach(function() {
spyOn(dbView, "render"); spyOn(dbView, "render");
spyOn(dbView, "unrender"); spyOn(dbView, "unrender");
view = new window.ClusterServerView();
okPair = { okPair = {
primary: { primary: {
name: "Pavel", name: "Pavel",
@ -141,7 +147,14 @@
deadBkp, deadBkp,
deadPrim deadPrim
]; ];
view.fakeData = fakeServers; dbServers = {
getList: function() {
return fakeServers;
}
};
view = new window.ClusterServerView({
collection: dbServers
});
view.render(); view.render();
}); });

View File

@ -21,7 +21,7 @@
describe("rendering", function() { describe("rendering", function() {
var s1, s2, s3, shards, var s1, s2, s3, shards, shardCol,
checkButtonContent = function(col, cls) { checkButtonContent = function(col, cls) {
var btn = document.getElementById(col.name); var btn = document.getElementById(col.name);
expect(btn).toBeOfClass("btn"); expect(btn).toBeOfClass("btn");
@ -50,8 +50,14 @@
s2, s2,
s3 s3
]; ];
view = new window.ClusterShardsView(); shardCol = {
view.fakeData.shards = shards; getList: function() {
return shards;
}
};
view = new window.ClusterShardsView({
collection: shardCol
});
view.render(); view.render();
}); });