mirror of https://gitee.com/bigwinds/arangodb
Removed CMS from Apps, can be downloaded via aal
This commit is contained in:
parent
0c4ef2215b
commit
17cb716bdc
|
@ -1,29 +0,0 @@
|
|||
Arango CMS
|
||||
=======
|
||||
|
||||
This is a Content Management System for the ArangoDB.
|
||||
It is based on struct information.
|
||||
|
||||
|
||||
# How To Use
|
||||
|
||||
More details will be added as soon as struct information is fully implemented.
|
||||
|
||||
## Add a Collection that should be managed
|
||||
|
||||
* Add a Collection you would like to manage.
|
||||
* Add struct information for this collection.
|
||||
|
||||
|
||||
## Enable the CMS
|
||||
Mount the CMS:
|
||||
|
||||
arangosh> aal = require('org/arangodb/aal')
|
||||
arangosh> aal.installApp("arangoCMS", "/cms")
|
||||
|
||||
Point your browser to `http://localhost:8529/cms/` to access the FrontEnd.
|
||||
You should now see a page with a navigation bar on top.
|
||||
This navigation bar should contain all collections you added struct information to.
|
||||
By clicking on one of these tabs you can access the contents of the respective collection.
|
||||
Each entry will offer you two options: Edit and Delete at the beginning of the row.
|
||||
In addition an option is given to add a new Document to your collection.
|
Binary file not shown.
Before Width: | Height: | Size: 9.1 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -1,15 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Arango DB Content Management System</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="tabbable" id="navi">
|
||||
</div>
|
||||
<div id="content"></div>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,46 +0,0 @@
|
|||
app = app || {};
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
app.ContentCollectionFactory = function () {
|
||||
this.create = function(name, callback) {
|
||||
$.get("structs/" + name, function(data) {
|
||||
var defaults = {},
|
||||
columns = [];
|
||||
_.each(data.attributes, function (content, name) {
|
||||
switch (content.type) {
|
||||
case "number":
|
||||
defaults[name] = 0;
|
||||
break;
|
||||
case "string":
|
||||
defaults[name] = "";
|
||||
break;
|
||||
default:
|
||||
defaults[name] = "";
|
||||
break;
|
||||
}
|
||||
columns.push({
|
||||
name: name,
|
||||
type: content.type
|
||||
});
|
||||
});
|
||||
columns = _.sortBy(columns, function(c){ return c.name; });
|
||||
var Content = Backbone.Model.extend({
|
||||
defaults: defaults,
|
||||
idAttribute: "_key"
|
||||
}),
|
||||
ContentCollection = Backbone.Collection.extend({
|
||||
model: Content,
|
||||
url: "content/" + name,
|
||||
|
||||
getColumns: function() {
|
||||
return columns;
|
||||
}
|
||||
}),
|
||||
collection = new ContentCollection();
|
||||
callback(collection);
|
||||
});
|
||||
};
|
||||
};
|
||||
}());
|
|
@ -1,11 +0,0 @@
|
|||
/*global Backbone */
|
||||
var app = app || {};
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
|
||||
app.MonitoredCollection = Backbone.Collection.extend({
|
||||
url: "list"
|
||||
});
|
||||
}());
|
|
@ -1,37 +0,0 @@
|
|||
/*global Backbone */
|
||||
var app = app || {};
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
// Todo Router
|
||||
// ----------
|
||||
var CMSRouter = Backbone.Router.extend({
|
||||
initialize: function() {
|
||||
this.navi = new app.NaviView();
|
||||
this.factory = new app.ContentCollectionFactory();
|
||||
this.welcome = new app.WelcomeView();
|
||||
},
|
||||
|
||||
routes: {
|
||||
"collection/:name": "displayCollection",
|
||||
"": "displayWelcome"
|
||||
},
|
||||
|
||||
displayWelcome: function () {
|
||||
this.navi.render();
|
||||
this.welcome.render();
|
||||
},
|
||||
|
||||
displayCollection: function (name) {
|
||||
this.navi.render(name);
|
||||
this.factory.create(name, function(res) {
|
||||
var view = new app.ContentView({collection: res});
|
||||
view.render();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.router = new CMSRouter();
|
||||
Backbone.history.start();
|
||||
})();
|
|
@ -1,59 +0,0 @@
|
|||
var app = app || {};
|
||||
|
||||
$(function () {
|
||||
'use strict';
|
||||
|
||||
app.ContentView = Backbone.View.extend({
|
||||
|
||||
template: new EJS({url: 'templates/contentView.ejs'}),
|
||||
|
||||
el: "#content",
|
||||
|
||||
events: {
|
||||
"click .delete": "deleteDocument",
|
||||
"click #addNew": "addDocument",
|
||||
"click .edit": "editDocument"
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.randomNumber = Math.random();
|
||||
this.collection.fetch({
|
||||
success: function() {
|
||||
self.render();
|
||||
}
|
||||
});
|
||||
this.collection.bind("change", self.render.bind(self));
|
||||
this.collection.bind("remove", self.render.bind(self));
|
||||
},
|
||||
|
||||
deleteDocument: function(event) {
|
||||
var _id = $(event.currentTarget).closest("tr").attr("id");
|
||||
this.collection.get(_id).destroy();
|
||||
},
|
||||
|
||||
addDocument: function() {
|
||||
var cols = this.collection.getColumns(),
|
||||
modal = new app.NewView({collection: this.collection, columns: cols});
|
||||
modal.render();
|
||||
},
|
||||
|
||||
editDocument: function(event) {
|
||||
|
||||
var _id = $(event.currentTarget).closest("tr").attr("id"),
|
||||
doc = this.collection.get(_id),
|
||||
cols = this.collection.getColumns(),
|
||||
modal = new app.EditView({model: doc, columns: cols});
|
||||
modal.render();
|
||||
},
|
||||
|
||||
// Re-render the titles of the todo item.
|
||||
render: function () {
|
||||
$(this.el).off();
|
||||
$(this.el).html(this.template.render({collection: this.collection}));
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
var app = app || {};
|
||||
|
||||
$(function () {
|
||||
'use strict';
|
||||
|
||||
app.EditSuperView = Backbone.View.extend({
|
||||
|
||||
template: new EJS({url: 'templates/editView.ejs'}),
|
||||
|
||||
el: "body",
|
||||
|
||||
events: {
|
||||
"click #store": "submit",
|
||||
"keypress": "editOnEnter",
|
||||
"hidden": "hidden"
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.columns = this.options.columns;
|
||||
this.validationObj = {};
|
||||
var rules = {},
|
||||
messages = {},
|
||||
self = this,
|
||||
highlight = function(element) {
|
||||
$(element).closest('.control-group').removeClass('success').addClass('error');
|
||||
},
|
||||
success = function(element) {
|
||||
element
|
||||
.text('OK!').addClass('valid')
|
||||
.closest('.control-group').removeClass('error').addClass('success');
|
||||
},
|
||||
submitHandler = function() {
|
||||
self.save();
|
||||
};
|
||||
_.each(this.columns, function(c) {
|
||||
var rule = {},
|
||||
msg = {};
|
||||
rule.required = true;
|
||||
msg.required = "Enter a " + c.name;
|
||||
switch (c.type) {
|
||||
case "string":
|
||||
rule.minlength = 1;
|
||||
msg.minlength = $.format("Enter at least {0} characters");
|
||||
break;
|
||||
case "boolean":
|
||||
delete rule.required;
|
||||
delete msg.required;
|
||||
break;
|
||||
case "number":
|
||||
rule.number = true;
|
||||
msg.number = "Please enter a number";
|
||||
break;
|
||||
case "email":
|
||||
rule.email = true;
|
||||
msg.email = "Enter a valid email";
|
||||
break;
|
||||
case "url":
|
||||
rule.url = true;
|
||||
msg.url = "Enter a valid url";
|
||||
break;
|
||||
default:
|
||||
rule.minlength = 1;
|
||||
msg.minlength = $.format("Enter at least {0} characters");
|
||||
}
|
||||
|
||||
rules[c.name] = rule;
|
||||
messages[c.name] = msg;
|
||||
});
|
||||
this.validationObj.rules = rules;
|
||||
this.validationObj.highlight = highlight;
|
||||
this.validationObj.success = success;
|
||||
this.validationObj.messages = messages;
|
||||
this.validationObj.submitHandler = submitHandler;
|
||||
|
||||
},
|
||||
|
||||
submit: function(e) {
|
||||
$('#document_form').submit();
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
editOnEnter: function(e) {
|
||||
if (e.keyCode === 13) {
|
||||
this.submit();
|
||||
}
|
||||
},
|
||||
|
||||
hidden: function () {
|
||||
$('#document_modal').remove();
|
||||
},
|
||||
|
||||
parse: function() {
|
||||
var obj = {};
|
||||
_.each(this.columns, function(c) {
|
||||
var name = c.name,
|
||||
val = $("#" + name).val();
|
||||
switch(c.type) {
|
||||
case "string":
|
||||
case "url":
|
||||
case "email":
|
||||
obj[name] = val;
|
||||
break;
|
||||
case "number":
|
||||
obj[name] = parseFloat(val);
|
||||
break;
|
||||
case "boolean":
|
||||
obj[name] = $("#" + name).prop("checked");
|
||||
break;
|
||||
default:
|
||||
obj[name] = val;
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
},
|
||||
|
||||
|
||||
activateValidation: function () {
|
||||
$('#document_form').validate(this.validationObj);
|
||||
},
|
||||
|
||||
indicateError: function(field, msg) {
|
||||
field.attr("style", "background-color:rgba(255, 0, 0, 0.5)");
|
||||
alert(msg);
|
||||
},
|
||||
|
||||
|
||||
superRender: function (data) {
|
||||
$(this.el).off();
|
||||
$(this.el).append(this.template.render(data));
|
||||
this.delegateEvents();
|
||||
this.activateValidation();
|
||||
$('#document_modal').modal("show");
|
||||
|
||||
}
|
||||
});
|
||||
}());
|
|
@ -1,19 +0,0 @@
|
|||
var app = app || {};
|
||||
|
||||
$(function () {
|
||||
'use strict';
|
||||
|
||||
app.EditView = app.EditSuperView.extend({
|
||||
|
||||
save: function() {
|
||||
var obj = this.parse();
|
||||
this.model.save(obj);
|
||||
$('#document_modal').modal('hide');
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.superRender({model: this.model, columns: this.columns});
|
||||
return this;
|
||||
}
|
||||
});
|
||||
}());
|
|
@ -1,39 +0,0 @@
|
|||
var app = app || {};
|
||||
|
||||
$(function () {
|
||||
'use strict';
|
||||
|
||||
app.NaviView = Backbone.View.extend({
|
||||
|
||||
template: new EJS({url: 'templates/naviView.ejs'}),
|
||||
|
||||
el: "#navi",
|
||||
|
||||
events: {
|
||||
"click li": "navigate"
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.collection = new app.MonitoredCollection();
|
||||
this.collection.fetch({
|
||||
success: function() {
|
||||
self.render();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
navigate: function(event) {
|
||||
app.router.navigate("collection/" + $(event.currentTarget).attr("id"), {trigger: true});
|
||||
},
|
||||
|
||||
// Re-render the titles of the todo item.
|
||||
render: function (selection) {
|
||||
$(this.el).html(this.template.render({
|
||||
collection: this.collection,
|
||||
selected: selection
|
||||
}));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
}());
|
|
@ -1,19 +0,0 @@
|
|||
var app = app || {};
|
||||
|
||||
$(function () {
|
||||
'use strict';
|
||||
|
||||
app.NewView = app.EditSuperView.extend({
|
||||
|
||||
save: function() {
|
||||
var obj = this.parse();
|
||||
this.collection.create(obj);
|
||||
$('#document_modal').modal('hide');
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.superRender({columns: this.columns});
|
||||
return this;
|
||||
}
|
||||
});
|
||||
}());
|
|
@ -1,17 +0,0 @@
|
|||
var app = app || {};
|
||||
|
||||
$(function () {
|
||||
'use strict';
|
||||
|
||||
app.WelcomeView = Backbone.View.extend({
|
||||
|
||||
template: new EJS({url: 'templates/welcomeView.ejs'}),
|
||||
|
||||
el: "#content",
|
||||
|
||||
render: function () {
|
||||
$(this.el).html(this.template.text);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
}());
|
|
@ -1,31 +0,0 @@
|
|||
<% cols = this.data.collection.getColumns() %>
|
||||
<table class="table table-condensed table-bordered">
|
||||
<tr>
|
||||
<th>Actions</th>
|
||||
<th>_key</th>
|
||||
<% _.each(cols, function(c) { %>
|
||||
<th><%=c.name%></th>
|
||||
<%});%>
|
||||
</tr>
|
||||
<% this.data.collection.each(function (d) { %>
|
||||
<tr id=<%=d.get("_key")%>>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a class="btn edit"><i class="icon-edit"></i></a>
|
||||
<a class="btn delete"><i class="icon-trash"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
<td><%=d.get("_key")%></td>
|
||||
<% _.each(cols, function(c) { %>
|
||||
<td><%=d.get(c.name)%></td>
|
||||
<% }); %>
|
||||
</tr>
|
||||
<% }) %>
|
||||
</table>
|
||||
<div id="cmsMenuBar">
|
||||
<form class="form-inline">
|
||||
<button class="btn new" id="addNew">Add new Document</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
<% var m = this.data.model,
|
||||
cs = this.data.columns;
|
||||
%>
|
||||
|
||||
<%
|
||||
var templ = new EJS({url: 'templates/inputView.ejs'});
|
||||
%>
|
||||
|
||||
<div id="document_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
|
||||
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<%if (m !== undefined) {%>
|
||||
<h3>Edit Document</h3>
|
||||
<% } else { %>
|
||||
<h3>New Document</h3>
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form id="document_form" class="form-horizontal">
|
||||
<% if(m !== undefined) {%>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="_key">_key</label>
|
||||
<div class="controls">
|
||||
<label class="control-label" id="_key"><%=m.get("_key")%></label>
|
||||
</div>
|
||||
</div>
|
||||
<%}
|
||||
_.each(cs, function(c) { %>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="<%=c.name%>"><%=c.name%></label>
|
||||
<%=templ.render({col: c, mod: m})%>
|
||||
</div>
|
||||
<%});%>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="store" class="btn btn-success pull-right">Save</button>
|
||||
</div>
|
||||
</div>
|
|
@ -1,31 +0,0 @@
|
|||
<%
|
||||
var c = this.data.col,
|
||||
m = this.data.mod,
|
||||
val,
|
||||
n = c.name
|
||||
t = c.type;
|
||||
if (m !== undefined) {
|
||||
val = m.get(c.name);
|
||||
} else {
|
||||
val = null;
|
||||
}
|
||||
%>
|
||||
<div class="controls">
|
||||
<%switch(t) {
|
||||
case "string":
|
||||
%><input type="text" id="<%=n%>" placeholder="<%=n%>" name="<%=n%>" value=<%=val%>></input><%
|
||||
break;
|
||||
case "number":
|
||||
%><input type="text" id="<%=n%>" placeholder="<%=n%>" name="<%=n%>" value=<%=val%>></input><%
|
||||
break;
|
||||
case "boolean":
|
||||
if (val) {
|
||||
%><input type="checkbox" id="<%=n%>" name="<%=n%>" checked></input><%
|
||||
} else {
|
||||
%><input type="checkbox" id="<%=n%>" name="<%=n%>"></input><%
|
||||
}
|
||||
break;
|
||||
default:
|
||||
%><input type="text" id="<%=n%>" placeholder="<%=n%>" name="<%=n%>" value=<%=val%>></input><%
|
||||
} %>
|
||||
</div>
|
|
@ -1,6 +0,0 @@
|
|||
<% var sel = this.data.selected; %>
|
||||
<ul class="nav nav-tabs">
|
||||
<% this.data.collection.each(function(i) { %>
|
||||
<li id=<%=i.get("name")%> <%=sel === i.get("name")?"class=\"active\"":""%>><a><%=i.get("name")%></a></li>
|
||||
<% });%>
|
||||
</ul>
|
|
@ -1 +0,0 @@
|
|||
<h1 id="welcome">Welcome</h1>
|
|
@ -1,681 +0,0 @@
|
|||
jasmine.HtmlReporterHelpers = {};
|
||||
|
||||
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
||||
var results = child.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
|
||||
var parentDiv = this.dom.summary;
|
||||
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
|
||||
var parent = child[parentSuite];
|
||||
|
||||
if (parent) {
|
||||
if (typeof this.views.suites[parent.id] == 'undefined') {
|
||||
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
|
||||
}
|
||||
parentDiv = this.views.suites[parent.id].element;
|
||||
}
|
||||
|
||||
parentDiv.appendChild(childElement);
|
||||
};
|
||||
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
|
||||
for(var fn in jasmine.HtmlReporterHelpers) {
|
||||
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter = function(_doc) {
|
||||
var self = this;
|
||||
var doc = _doc || window.document;
|
||||
|
||||
var reporterView;
|
||||
|
||||
var dom = {};
|
||||
|
||||
// Jasmine Reporter Public Interface
|
||||
self.logRunningSpecs = false;
|
||||
|
||||
self.reportRunnerStarting = function(runner) {
|
||||
var specs = runner.specs() || [];
|
||||
|
||||
if (specs.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
createReporterDom(runner.env.versionString());
|
||||
doc.body.appendChild(dom.reporter);
|
||||
setExceptionHandling();
|
||||
|
||||
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
|
||||
reporterView.addSpecs(specs, self.specFilter);
|
||||
};
|
||||
|
||||
self.reportRunnerResults = function(runner) {
|
||||
reporterView && reporterView.complete();
|
||||
};
|
||||
|
||||
self.reportSuiteResults = function(suite) {
|
||||
reporterView.suiteComplete(suite);
|
||||
};
|
||||
|
||||
self.reportSpecStarting = function(spec) {
|
||||
if (self.logRunningSpecs) {
|
||||
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
self.reportSpecResults = function(spec) {
|
||||
reporterView.specComplete(spec);
|
||||
};
|
||||
|
||||
self.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.specFilter = function(spec) {
|
||||
if (!focusedSpecName()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return spec.getFullName().indexOf(focusedSpecName()) === 0;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
function focusedSpecName() {
|
||||
var specName;
|
||||
|
||||
(function memoizeFocusedSpec() {
|
||||
if (specName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var paramMap = [];
|
||||
var params = jasmine.HtmlReporter.parameters(doc);
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
specName = paramMap.spec;
|
||||
})();
|
||||
|
||||
return specName;
|
||||
}
|
||||
|
||||
function createReporterDom(version) {
|
||||
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
|
||||
dom.banner = self.createDom('div', { className: 'banner' },
|
||||
self.createDom('span', { className: 'title' }, "Jasmine "),
|
||||
self.createDom('span', { className: 'version' }, version)),
|
||||
|
||||
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
|
||||
dom.alert = self.createDom('div', {className: 'alert'},
|
||||
self.createDom('span', { className: 'exceptions' },
|
||||
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
|
||||
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
|
||||
dom.results = self.createDom('div', {className: 'results'},
|
||||
dom.summary = self.createDom('div', { className: 'summary' }),
|
||||
dom.details = self.createDom('div', { id: 'details' }))
|
||||
);
|
||||
}
|
||||
|
||||
function noTryCatch() {
|
||||
return window.location.search.match(/catch=false/);
|
||||
}
|
||||
|
||||
function searchWithCatch() {
|
||||
var params = jasmine.HtmlReporter.parameters(window.document);
|
||||
var removed = false;
|
||||
var i = 0;
|
||||
|
||||
while (!removed && i < params.length) {
|
||||
if (params[i].match(/catch=/)) {
|
||||
params.splice(i, 1);
|
||||
removed = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (jasmine.CATCH_EXCEPTIONS) {
|
||||
params.push("catch=false");
|
||||
}
|
||||
|
||||
return params.join("&");
|
||||
}
|
||||
|
||||
function setExceptionHandling() {
|
||||
var chxCatch = document.getElementById('no_try_catch');
|
||||
|
||||
if (noTryCatch()) {
|
||||
chxCatch.setAttribute('checked', true);
|
||||
jasmine.CATCH_EXCEPTIONS = false;
|
||||
}
|
||||
chxCatch.onclick = function() {
|
||||
window.location.search = searchWithCatch();
|
||||
};
|
||||
}
|
||||
};
|
||||
jasmine.HtmlReporter.parameters = function(doc) {
|
||||
var paramStr = doc.location.search.substring(1);
|
||||
var params = [];
|
||||
|
||||
if (paramStr.length > 0) {
|
||||
params = paramStr.split('&');
|
||||
}
|
||||
return params;
|
||||
}
|
||||
jasmine.HtmlReporter.sectionLink = function(sectionName) {
|
||||
var link = '?';
|
||||
var params = [];
|
||||
|
||||
if (sectionName) {
|
||||
params.push('spec=' + encodeURIComponent(sectionName));
|
||||
}
|
||||
if (!jasmine.CATCH_EXCEPTIONS) {
|
||||
params.push("catch=false");
|
||||
}
|
||||
if (params.length > 0) {
|
||||
link += params.join("&");
|
||||
}
|
||||
|
||||
return link;
|
||||
};
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
|
||||
jasmine.HtmlReporter.ReporterView = function(dom) {
|
||||
this.startedAt = new Date();
|
||||
this.runningSpecCount = 0;
|
||||
this.completeSpecCount = 0;
|
||||
this.passedCount = 0;
|
||||
this.failedCount = 0;
|
||||
this.skippedCount = 0;
|
||||
|
||||
this.createResultsMenu = function() {
|
||||
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
|
||||
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
|
||||
' | ',
|
||||
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
|
||||
|
||||
this.summaryMenuItem.onclick = function() {
|
||||
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
|
||||
};
|
||||
|
||||
this.detailsMenuItem.onclick = function() {
|
||||
showDetails();
|
||||
};
|
||||
};
|
||||
|
||||
this.addSpecs = function(specs, specFilter) {
|
||||
this.totalSpecCount = specs.length;
|
||||
|
||||
this.views = {
|
||||
specs: {},
|
||||
suites: {}
|
||||
};
|
||||
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
var spec = specs[i];
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
|
||||
if (specFilter(spec)) {
|
||||
this.runningSpecCount++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.specComplete = function(spec) {
|
||||
this.completeSpecCount++;
|
||||
|
||||
if (isUndefined(this.views.specs[spec.id])) {
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
|
||||
}
|
||||
|
||||
var specView = this.views.specs[spec.id];
|
||||
|
||||
switch (specView.status()) {
|
||||
case 'passed':
|
||||
this.passedCount++;
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.failedCount++;
|
||||
break;
|
||||
|
||||
case 'skipped':
|
||||
this.skippedCount++;
|
||||
break;
|
||||
}
|
||||
|
||||
specView.refresh();
|
||||
this.refresh();
|
||||
};
|
||||
|
||||
this.suiteComplete = function(suite) {
|
||||
var suiteView = this.views.suites[suite.id];
|
||||
if (isUndefined(suiteView)) {
|
||||
return;
|
||||
}
|
||||
suiteView.refresh();
|
||||
};
|
||||
|
||||
this.refresh = function() {
|
||||
|
||||
if (isUndefined(this.resultsMenu)) {
|
||||
this.createResultsMenu();
|
||||
}
|
||||
|
||||
// currently running UI
|
||||
if (isUndefined(this.runningAlert)) {
|
||||
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
|
||||
dom.alert.appendChild(this.runningAlert);
|
||||
}
|
||||
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
|
||||
|
||||
// skipped specs UI
|
||||
if (isUndefined(this.skippedAlert)) {
|
||||
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
|
||||
}
|
||||
|
||||
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.skippedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.skippedAlert);
|
||||
}
|
||||
|
||||
// passing specs UI
|
||||
if (isUndefined(this.passedAlert)) {
|
||||
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
|
||||
}
|
||||
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
|
||||
|
||||
// failing specs UI
|
||||
if (isUndefined(this.failedAlert)) {
|
||||
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
|
||||
}
|
||||
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
|
||||
|
||||
if (this.failedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.failedAlert);
|
||||
dom.alert.appendChild(this.resultsMenu);
|
||||
}
|
||||
|
||||
// summary info
|
||||
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
|
||||
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
|
||||
};
|
||||
|
||||
this.complete = function() {
|
||||
dom.alert.removeChild(this.runningAlert);
|
||||
|
||||
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.failedCount === 0) {
|
||||
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
|
||||
} else {
|
||||
showDetails();
|
||||
}
|
||||
|
||||
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function showDetails() {
|
||||
if (dom.reporter.className.search(/showDetails/) === -1) {
|
||||
dom.reporter.className += " showDetails";
|
||||
}
|
||||
}
|
||||
|
||||
function isUndefined(obj) {
|
||||
return typeof obj === 'undefined';
|
||||
}
|
||||
|
||||
function isDefined(obj) {
|
||||
return !isUndefined(obj);
|
||||
}
|
||||
|
||||
function specPluralizedFor(count) {
|
||||
var str = count + " spec";
|
||||
if (count > 1) {
|
||||
str += "s"
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
|
||||
|
||||
|
||||
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
|
||||
this.spec = spec;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.symbol = this.createDom('li', { className: 'pending' });
|
||||
this.dom.symbolSummary.appendChild(this.symbol);
|
||||
|
||||
this.summary = this.createDom('div', { className: 'specSummary' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.description)
|
||||
);
|
||||
|
||||
this.detail = this.createDom('div', { className: 'specDetail' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.getFullName())
|
||||
);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.spec);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
|
||||
this.symbol.className = this.status();
|
||||
|
||||
switch (this.status()) {
|
||||
case 'skipped':
|
||||
break;
|
||||
|
||||
case 'passed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
this.appendFailureDetail();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
|
||||
this.summary.className += ' ' + this.status();
|
||||
this.appendToSummary(this.spec, this.summary);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
||||
this.detail.className += ' ' + this.status();
|
||||
|
||||
var resultItems = this.spec.results().getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
this.detail.appendChild(messagesDiv);
|
||||
this.dom.details.appendChild(this.detail);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
||||
this.suite = suite;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.element = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
|
||||
);
|
||||
|
||||
this.appendToSummary(this.suite, this.element);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.suite);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
|
||||
this.element.className += " " + this.status();
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
|
||||
|
||||
/* @deprecated Use jasmine.HtmlReporter instead
|
||||
*/
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('span', { className: 'title' }, "Jasmine"),
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onclick = function(evt) {
|
||||
if (showPassed.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onclick = function(evt) {
|
||||
if (showSkipped.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap.spec) {
|
||||
return true;
|
||||
}
|
||||
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -1,44 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test CMS</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<script type="text/javascript" src="../app.js"></script>
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var htmlReporter = new jasmine.HtmlReporter();
|
||||
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return htmlReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
jasmineEnv.execute();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -1,173 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global EdgeShaper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
describe('Content Collection Factory', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
app = app || {};
|
||||
});
|
||||
|
||||
it('should bind itself to the app scope', function() {
|
||||
expect(app.ContentCollectionFactory).toBeDefined();
|
||||
});
|
||||
|
||||
describe('given a struct URL', function() {
|
||||
|
||||
var factory;
|
||||
|
||||
beforeEach(function() {
|
||||
factory = new app.ContentCollectionFactory();
|
||||
});
|
||||
|
||||
it('should be able to create a content collection for Strings', function() {
|
||||
|
||||
var called;
|
||||
|
||||
runs(function() {
|
||||
called = false;
|
||||
factory.create("String", function(collection) {
|
||||
expect(collection).toBeDefined();
|
||||
var firstModel = collection.create();
|
||||
expect(firstModel.get("name")).toBeDefined();
|
||||
expect(firstModel.get("name")).toEqual("");
|
||||
called = true;
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return called;
|
||||
}, 2000, "Creation should have been called.");
|
||||
|
||||
runs(function() {
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to create a content collection for Numbers', function() {
|
||||
|
||||
var called;
|
||||
|
||||
runs(function() {
|
||||
called = false;
|
||||
factory.create("Number", function(collection) {
|
||||
expect(collection).toBeDefined();
|
||||
var firstModel = collection.create();
|
||||
expect(firstModel.get("int")).toBeDefined();
|
||||
expect(firstModel.get("int")).toEqual(0);
|
||||
expect(firstModel.get("double")).toBeDefined();
|
||||
expect(firstModel.get("double")).toEqual(0);
|
||||
called = true;
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return called;
|
||||
}, 2000, "Creation should have been called.");
|
||||
|
||||
runs(function() {
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should be able to create a content collection for different attributes', function() {
|
||||
|
||||
var called;
|
||||
|
||||
runs(function() {
|
||||
called = false;
|
||||
factory.create("All", function(collection) {
|
||||
expect(collection).toBeDefined();
|
||||
var firstModel = collection.create();
|
||||
expect(firstModel.get("int")).toBeDefined();
|
||||
expect(firstModel.get("int")).toEqual(0);
|
||||
expect(firstModel.get("double")).toBeDefined();
|
||||
expect(firstModel.get("double")).toEqual(0);
|
||||
expect(firstModel.get("name")).toBeDefined();
|
||||
expect(firstModel.get("name")).toEqual("");
|
||||
called = true;
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return called;
|
||||
}, 2000, "Creation should have been called.");
|
||||
|
||||
runs(function() {
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should be able to request the columns', function() {
|
||||
|
||||
var called;
|
||||
|
||||
runs(function() {
|
||||
called = false;
|
||||
factory.create("Number", function(collection) {
|
||||
expect(collection.getColumns).toBeDefined();
|
||||
expect(collection.getColumns).toEqual(jasmine.any(Function));
|
||||
expect(collection.getColumns()).toEqual([
|
||||
{
|
||||
name: "double",
|
||||
type: "number"
|
||||
},
|
||||
{
|
||||
name: "int",
|
||||
type: "number"
|
||||
}
|
||||
]);
|
||||
called = true;
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return called;
|
||||
}, 2000, "Creation should have been called.");
|
||||
|
||||
runs(function() {
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}());
|
|
@ -1,234 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global EdgeShaper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
describe('Content Viewer', function() {
|
||||
|
||||
var contentDiv;
|
||||
|
||||
beforeEach(function() {
|
||||
app = app || {};
|
||||
contentDiv = document.createElement("div");
|
||||
contentDiv.id = "content";
|
||||
document.body.appendChild(contentDiv);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
document.body.removeChild(contentDiv);
|
||||
});
|
||||
|
||||
it('should bind itself to the app scope', function() {
|
||||
expect(app.ContentView).toBeDefined();
|
||||
});
|
||||
|
||||
describe('checking display', function() {
|
||||
var collection,
|
||||
callback;
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
runs(function() {
|
||||
callback = false;
|
||||
var factory = new app.ContentCollectionFactory();
|
||||
factory.create("All", function(res) {
|
||||
collection = res;
|
||||
var view = new app.ContentView({collection: collection});
|
||||
view.render();
|
||||
callback = true;
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return callback;
|
||||
}, 1000, "The collection should have been loaded.")
|
||||
|
||||
waits(1000);
|
||||
});
|
||||
|
||||
it('should be able to display content of a collection', function() {
|
||||
|
||||
runs(function() {
|
||||
var tableSelector = "#content table",
|
||||
rowsSelector = tableSelector + " tr",
|
||||
headerRow = $("> th", $(rowsSelector).eq(0)),
|
||||
firstRow = $("> td", $(rowsSelector).eq(1)),
|
||||
contentActions = $(".btn", firstRow.eq(0));
|
||||
expect($(tableSelector).length).toEqual(1);
|
||||
expect($(rowsSelector).length).toEqual(2);
|
||||
|
||||
expect(headerRow.length).toEqual(5);
|
||||
expect(headerRow.eq(0).text()).toEqual("Actions");
|
||||
expect(headerRow.eq(1).text()).toEqual("_key");
|
||||
expect(headerRow.eq(2).text()).toEqual("double");
|
||||
expect(headerRow.eq(3).text()).toEqual("int");
|
||||
expect(headerRow.eq(4).text()).toEqual("name");
|
||||
|
||||
expect(firstRow.length).toEqual(5);
|
||||
expect($(rowsSelector).eq(1).attr("id")).toEqual("1");
|
||||
expect(firstRow.eq(1).text()).toEqual("1");
|
||||
expect(firstRow.eq(2).text()).toEqual("4.5");
|
||||
expect(firstRow.eq(3).text()).toEqual("4");
|
||||
expect(firstRow.eq(4).text()).toEqual("Test");
|
||||
expect(contentActions.length).toEqual(2);
|
||||
|
||||
expect(contentActions.eq(0).hasClass("edit")).toBeTruthy();
|
||||
expect(contentActions.eq(1).hasClass("delete")).toBeTruthy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should display the add new entry', function() {
|
||||
|
||||
runs(function() {
|
||||
var bar = $("#content div#cmsMenuBar"),
|
||||
addNew = $("button#addNew", bar);
|
||||
expect(bar.length).toEqual(1);
|
||||
expect(addNew.length).toEqual(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('checking actions', function() {
|
||||
|
||||
var collection,
|
||||
callback;
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
runs(function() {
|
||||
callback = false;
|
||||
var factory = new app.ContentCollectionFactory();
|
||||
factory.create("All", function(res) {
|
||||
collection = res;
|
||||
var view = new app.ContentView({collection: collection});
|
||||
view.render();
|
||||
callback = true;
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return callback;
|
||||
}, 1000, "The collection should have been loaded.")
|
||||
|
||||
waits(1000);
|
||||
});
|
||||
|
||||
/*
|
||||
it('should be possible to add a new item', function() {
|
||||
|
||||
runs(function() {
|
||||
spyOn(collection, "create");
|
||||
|
||||
$("#addNew").click();
|
||||
$("#double").attr("value", "1.34");
|
||||
$("#int").attr("value", "42");
|
||||
$("#name").attr("value", "Circus");
|
||||
$("#store").click();
|
||||
|
||||
expect(collection.create).wasCalledWith({
|
||||
double: 1.34,
|
||||
int: 42,
|
||||
name: "Circus"
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#document_modal").length === 0;
|
||||
}, 1000, "The modal view should have been disappeared.");
|
||||
|
||||
});
|
||||
*/
|
||||
it('should be possible to edit an item', function() {
|
||||
|
||||
runs(function() {
|
||||
var firstCell = $("> td", $("#content table tr").eq(1)).eq(0),
|
||||
model = collection.findWhere({
|
||||
double: 4.5,
|
||||
int: 4,
|
||||
name: "Test"
|
||||
});
|
||||
|
||||
spyOn(model, "save");
|
||||
|
||||
$(".edit", firstCell).click();
|
||||
|
||||
expect($("#double").attr("value")).toEqual("4.5");
|
||||
expect($("#int").attr("value")).toEqual("4");
|
||||
expect($("#name").attr("value")).toEqual("Test");
|
||||
|
||||
|
||||
$("#double").attr("value", "1.34");
|
||||
$("#int").attr("value", "42");
|
||||
$("#name").attr("value", "Circus");
|
||||
$("#store").click();
|
||||
|
||||
expect(model.save).wasCalledWith({
|
||||
double: 1.34,
|
||||
int: 42,
|
||||
name: "Circus"
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $("#document_modal").length === 0;
|
||||
}, 1000, "The modal view should have been disappeared.");
|
||||
|
||||
});
|
||||
|
||||
it('should be possible to delete an item', function() {
|
||||
var firstCell = $("> td", $("#content table tr").eq(1)).eq(0),
|
||||
model = collection.findWhere({
|
||||
double: 4.5,
|
||||
int: 4,
|
||||
name: "Test"
|
||||
});
|
||||
|
||||
spyOn(model, "destroy");
|
||||
|
||||
$(".delete", firstCell).click();
|
||||
|
||||
expect(model.destroy).toHaveBeenCalled();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}());
|
|
@ -1,492 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global EdgeShaper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var app = app || {};
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
|
||||
describe('Abstract Edit Dialog', function() {
|
||||
|
||||
var waitTime = 1000;
|
||||
|
||||
it('should bind itself to the app scope', function() {
|
||||
expect(app.EditSuperView).toBeDefined();
|
||||
});
|
||||
|
||||
describe('checking extension', function() {
|
||||
|
||||
var viewClass = app.EditSuperView.extend({
|
||||
save: function() {
|
||||
$('#document_modal').modal('hide');
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.superRender({columns: this.columns});
|
||||
return this;
|
||||
}
|
||||
}),
|
||||
view;
|
||||
|
||||
it('should open and close the dialog', function() {
|
||||
|
||||
runs(function() {
|
||||
|
||||
var columns = [];
|
||||
view = new viewClass({columns: columns});
|
||||
spyOn(view, "save");
|
||||
view.render();
|
||||
|
||||
expect($("#document_modal").length).toEqual(1);
|
||||
expect($(".modal-backdrop").length).toEqual(1);
|
||||
expect($(".modal-backdrop").hasClass("in")).toBeTruthy();
|
||||
|
||||
$(".modal-backdrop").click();
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $(".modal-backdrop").length === 0;
|
||||
}, 1000, "The modal view should have been disappered.");
|
||||
|
||||
runs(function() {
|
||||
expect($("#document_modal").length).toEqual(0);
|
||||
expect($(".modal-backdrop").length).toEqual(0);
|
||||
expect(view.save).wasNotCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should save on button click', function() {
|
||||
|
||||
runs(function() {
|
||||
|
||||
var columns = [];
|
||||
view = new viewClass({columns: columns});
|
||||
spyOn(view, "save").andCallThrough();
|
||||
view.render();
|
||||
|
||||
$("#store").click();
|
||||
expect(view.save).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $(".modal-backdrop").length === 0;
|
||||
}, 1000, "The modal view should have been disappered.");
|
||||
|
||||
|
||||
runs(function() {
|
||||
expect($("#document_modal").length).toEqual(0);
|
||||
expect($(".modal-backdrop").length).toEqual(0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should save on enter press', function() {
|
||||
|
||||
runs(function() {
|
||||
|
||||
var columns = [];
|
||||
view = new viewClass({columns: columns});
|
||||
spyOn(view, "save").andCallThrough();
|
||||
view.render();
|
||||
|
||||
var e = $.Event("keypress");
|
||||
e.which = 13; //choose the one you want
|
||||
e.keyCode = 13;
|
||||
$("body").trigger(e);
|
||||
expect(view.save).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $(".modal-backdrop").length === 0;
|
||||
}, 1000, "The modal view should have been disappered.");
|
||||
|
||||
|
||||
runs(function() {
|
||||
expect($("#document_modal").length).toEqual(0);
|
||||
expect($(".modal-backdrop").length).toEqual(0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should only save once on enter press', function() {
|
||||
|
||||
runs(function() {
|
||||
var columns = [{
|
||||
name: "test",
|
||||
type: "string"
|
||||
}];
|
||||
view = new viewClass({columns: columns});
|
||||
spyOn(view, "save").andCallThrough();
|
||||
view.render();
|
||||
});
|
||||
|
||||
waits(1000);
|
||||
|
||||
runs(function() {
|
||||
$("#test").attr("value", "Meier");
|
||||
|
||||
|
||||
var e = $.Event("keypress");
|
||||
e.which = 13; //choose the one you want
|
||||
e.keyCode = 13;
|
||||
$("#document_form").trigger(e);
|
||||
|
||||
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $(".modal-backdrop").length === 0;
|
||||
}, 1000, "The modal view should have been disappered.");
|
||||
|
||||
|
||||
runs(function() {
|
||||
|
||||
expect($("#document_modal").length).toEqual(0);
|
||||
expect($(".modal-backdrop").length).toEqual(0);
|
||||
expect(view.save.calls.length).toEqual(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('checking validation', function() {
|
||||
|
||||
describe('checking numbers', function() {
|
||||
|
||||
var view;
|
||||
|
||||
beforeEach(function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "number"
|
||||
}];
|
||||
view = new viewClass({columns: columns});
|
||||
spyOn(view, "save").andCallThrough();
|
||||
view.render();
|
||||
|
||||
// Sorry have to wait until modal and validation is active.
|
||||
waits(waitTime);
|
||||
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
runs(function() {
|
||||
$(".modal-backdrop").click();;
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $(".modal-backdrop").length === 0;
|
||||
}, 1000, "The modal view should have been disappered.");
|
||||
|
||||
});
|
||||
|
||||
it('should store integer numbers', function() {
|
||||
$("#val").attr("value", "1");
|
||||
$("#store").click();
|
||||
expect(view.save).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should store decimal numbers', function() {
|
||||
$("#val").attr("value", "1.42");
|
||||
$("#store").click();
|
||||
expect(view.save).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should store negative numbers', function() {
|
||||
$("#val").attr("value", "-1");
|
||||
$("#store").click();
|
||||
expect(view.save).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not store characters', function() {
|
||||
$("#val").attr("value", "1.a");
|
||||
$("#store").click();
|
||||
expect(view.save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not store NaN', function() {
|
||||
$("#val").attr("value", "NaN");
|
||||
$("#store").click();
|
||||
expect(view.save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not store the empty string', function() {
|
||||
$("#val").attr("value", "");
|
||||
$("#store").click();
|
||||
expect(view.save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('checking strings', function() {
|
||||
|
||||
var view;
|
||||
|
||||
beforeEach(function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "string"
|
||||
}];
|
||||
view = new viewClass({columns: columns});
|
||||
spyOn(view, "save").andCallThrough();
|
||||
view.render();
|
||||
|
||||
// Sorry have to wait until modal and validation is active.
|
||||
waits(waitTime);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
runs(function() {
|
||||
$(".modal-backdrop").click();;
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $(".modal-backdrop").length === 0;
|
||||
}, 1000, "The modal view should have been disappered.");
|
||||
|
||||
});
|
||||
|
||||
it('should store any string', function() {
|
||||
$("#val").attr("value", "abc123");
|
||||
$("#store").click();
|
||||
expect(view.save).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not store the empty string', function() {
|
||||
$("#val").attr("value", "");
|
||||
$("#store").click();
|
||||
expect(view.save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('checking email', function() {
|
||||
|
||||
var view;
|
||||
|
||||
beforeEach(function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "email"
|
||||
}];
|
||||
view = new viewClass({columns: columns});
|
||||
spyOn(view, "save").andCallThrough();
|
||||
view.render();
|
||||
|
||||
// Sorry have to wait until modal and validation is active.
|
||||
waits(waitTime);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
runs(function() {
|
||||
$(".modal-backdrop").click();;
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $(".modal-backdrop").length === 0;
|
||||
}, 1000, "The modal view should have been disappered.");
|
||||
|
||||
});
|
||||
|
||||
it('should store a valid email', function() {
|
||||
$("#val").attr("value", "a@b.cd");
|
||||
$("#store").click();
|
||||
expect(view.save).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not store the empty string', function() {
|
||||
$("#val").attr("value", "");
|
||||
$("#store").click();
|
||||
expect(view.save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not store a string without @', function() {
|
||||
$("#val").attr("value", "ab.cd");
|
||||
$("#store").click();
|
||||
expect(view.save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not store a string without .', function() {
|
||||
$("#val").attr("value", "a@b");
|
||||
$("#store").click();
|
||||
expect(view.save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not store a string with @ and . in reverse order', function() {
|
||||
$("#val").attr("value", "a.b@cd");
|
||||
$("#store").click();
|
||||
expect(view.save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('checking display', function() {
|
||||
|
||||
afterEach(function() {
|
||||
runs(function() {
|
||||
$(".modal-backdrop").click();;
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $(".modal-backdrop").length === 0;
|
||||
}, 1000, "The modal view should have been disappered.");
|
||||
|
||||
});
|
||||
|
||||
it('should display a text-field for numbers', function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "number"
|
||||
}],
|
||||
view = new viewClass({columns: columns});
|
||||
view.render();
|
||||
expect($("#val").is("input")).toBeTruthy();
|
||||
expect($("#val").attr("type")).toEqual("text");
|
||||
});
|
||||
|
||||
it('should display a text-field for strings', function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "string"
|
||||
}],
|
||||
view = new viewClass({columns: columns});
|
||||
view.render();
|
||||
expect($("#val").is("input")).toBeTruthy();
|
||||
expect($("#val").attr("type")).toEqual("text");
|
||||
});
|
||||
|
||||
it('should display a text-field for emails', function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "email"
|
||||
}],
|
||||
view = new viewClass({columns: columns});
|
||||
view.render();
|
||||
expect($("#val").is("input")).toBeTruthy();
|
||||
expect($("#val").attr("type")).toEqual("text");
|
||||
});
|
||||
|
||||
it('should display a checkbox for booleans', function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "boolean"
|
||||
}],
|
||||
view = new viewClass({columns: columns});
|
||||
view.render();
|
||||
expect($("#val").is("input")).toBeTruthy();
|
||||
expect($("#val").attr("type")).toEqual("checkbox");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('checking parser', function() {
|
||||
|
||||
afterEach(function() {
|
||||
runs(function() {
|
||||
$(".modal-backdrop").click();;
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return $(".modal-backdrop").length === 0;
|
||||
}, 1000, "The modal view should have been disappered.");
|
||||
|
||||
});
|
||||
|
||||
it('should parse numbers', function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "number"
|
||||
}],
|
||||
view = new viewClass({columns: columns});
|
||||
view.render();
|
||||
$("#val").attr("value", "3.14");
|
||||
expect(view.parse()).toEqual({
|
||||
val: 3.14
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse strings', function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "string"
|
||||
}],
|
||||
view = new viewClass({columns: columns});
|
||||
view.render();
|
||||
$("#val").attr("value", "3.14");
|
||||
expect(view.parse()).toEqual({
|
||||
val: "3.14"
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse emails', function() {
|
||||
var columns = [{
|
||||
name: "val",
|
||||
type: "email"
|
||||
}],
|
||||
view = new viewClass({columns: columns});
|
||||
view.render();
|
||||
$("#val").attr("value", "a@b.cd");
|
||||
expect(view.parse()).toEqual({
|
||||
val: "a@b.cd"
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse booleans', function() {
|
||||
var columns = [{
|
||||
name: "val1",
|
||||
type: "boolean"
|
||||
},{
|
||||
name: "val2",
|
||||
type: "boolean"
|
||||
}],
|
||||
view = new viewClass({columns: columns});
|
||||
view.render();
|
||||
$("#val1").prop("checked", true);
|
||||
$("#val2").prop("checked", false);
|
||||
expect(view.parse()).toEqual({
|
||||
val1: true,
|
||||
val2: false
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}());
|
|
@ -1,76 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global EdgeShaper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
describe('Edit Document View', function() {
|
||||
|
||||
it('should correctly render the inherited view', function() {
|
||||
var cols = [{
|
||||
name: "string",
|
||||
type: "string"
|
||||
}],
|
||||
ModelClass = Backbone.Model.extend({
|
||||
defaults: {
|
||||
name: "fuxx"
|
||||
}
|
||||
}),
|
||||
model = new ModelClass(),
|
||||
view = new app.EditView({model: model, columns: cols});
|
||||
spyOn(view, "superRender");
|
||||
view.render();
|
||||
expect(view.superRender).wasCalledWith({
|
||||
model: model,
|
||||
columns: cols
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to create a new entry', function() {
|
||||
var cols = [],
|
||||
model = new Backbone.Model(),
|
||||
view = new app.EditView({model: model, columns: cols});
|
||||
spyOn(view, "parse").andCallFake(function() {
|
||||
return {fake: true};
|
||||
});
|
||||
spyOn(model, "save")
|
||||
view.save();
|
||||
expect(view.parse).wasCalled();
|
||||
expect(model.save).wasCalledWith({fake: true});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}());
|
|
@ -1,68 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global EdgeShaper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
describe('Monitored Collection', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
app = app || {};
|
||||
});
|
||||
|
||||
it('should bind itself to the app scope', function() {
|
||||
expect(app.MonitoredCollection).toBeDefined();
|
||||
});
|
||||
|
||||
it('should be able to fetch collections', function() {
|
||||
|
||||
var collection;
|
||||
|
||||
runs(function() {
|
||||
collection = new app.MonitoredCollection();
|
||||
collection.fetch();
|
||||
});
|
||||
|
||||
waits(1000);
|
||||
|
||||
runs(function() {
|
||||
expect(collection.findWhere({name: "String"})).toBeDefined();
|
||||
expect(collection.findWhere({name: "Number"})).toBeDefined();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}());
|
|
@ -1,166 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global EdgeShaper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
describe('Navigation Bar', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
app = app || {};
|
||||
});
|
||||
|
||||
it('should bind itself to the app scope', function() {
|
||||
expect(app.NaviView).toBeDefined();
|
||||
});
|
||||
|
||||
it('should be able to render all items', function() {
|
||||
|
||||
var div;
|
||||
|
||||
runs(function() {
|
||||
div = document.createElement("navi");
|
||||
div.id = "navi";
|
||||
document.body.appendChild(div);
|
||||
var view = new app.NaviView();
|
||||
view.render();
|
||||
});
|
||||
|
||||
waits(1000);
|
||||
|
||||
runs(function() {
|
||||
expect($("#navi ul").length).toEqual(1);
|
||||
expect($("#navi ul li").length).toEqual(2);
|
||||
|
||||
expect($("#navi ul li#String").length).toEqual(1);
|
||||
expect($("#navi ul li#Number").length).toEqual(1);
|
||||
|
||||
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should be able to activate the selected tab', function() {
|
||||
|
||||
var div, view;
|
||||
|
||||
runs(function() {
|
||||
div = document.createElement("navi");
|
||||
div.id = "navi";
|
||||
document.body.appendChild(div);
|
||||
view = new app.NaviView();
|
||||
|
||||
});
|
||||
|
||||
waits(1000);
|
||||
|
||||
runs(function() {
|
||||
view.render("String");
|
||||
});
|
||||
|
||||
waits(1000);
|
||||
|
||||
runs(function() {
|
||||
expect($("#navi ul").length).toEqual(1);
|
||||
expect($("#navi ul li").length).toEqual(2);
|
||||
expect($("#navi ul li#String.active").length).toEqual(1);
|
||||
expect($("#navi ul li#Number").length).toEqual(1);
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('if it is rendered', function() {
|
||||
|
||||
var div;
|
||||
|
||||
beforeEach(function() {
|
||||
runs(function() {
|
||||
div = document.createElement("navi");
|
||||
div.id = "navi";
|
||||
document.body.appendChild(div);
|
||||
var view = new app.NaviView();
|
||||
view.render();
|
||||
});
|
||||
|
||||
waits(1000);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
|
||||
it('should be able to navigate to String Collection', function() {
|
||||
|
||||
runs(function() {
|
||||
spyOn(app.router, "navigate");
|
||||
|
||||
$("#navi ul li#String").click();
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return app.router.navigate.wasCalled;
|
||||
}, 1000, "Navigation to String should have been called.");
|
||||
|
||||
runs(function() {
|
||||
expect(app.router.navigate).wasCalledWith("collection/String", {trigger: true});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should be able to navigate to Number Collection', function() {
|
||||
|
||||
runs(function() {
|
||||
spyOn(app.router, "navigate");
|
||||
|
||||
$("#navi ul li#Number").click();
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return app.router.navigate.wasCalled;
|
||||
}, 1000, "Navigation to Number should have been called.");
|
||||
|
||||
runs(function() {
|
||||
expect(app.router.navigate).wasCalledWith("collection/Number", {trigger: true});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}());
|
|
@ -1,68 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global EdgeShaper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
describe('New Document View', function() {
|
||||
|
||||
it('should correctly render the inherited view', function() {
|
||||
var cols = [{
|
||||
name: "string",
|
||||
type: "string"
|
||||
}],
|
||||
view = new app.NewView({collection: new Backbone.Collection(), columns: cols});
|
||||
spyOn(view, "superRender");
|
||||
view.render();
|
||||
expect(view.superRender).wasCalledWith({
|
||||
columns: cols
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to create a new entry', function() {
|
||||
var cols = [],
|
||||
collection = new Backbone.Collection(),
|
||||
view = new app.NewView({collection: collection, columns: cols});
|
||||
spyOn(view, "parse").andCallFake(function() {
|
||||
return {fake: true};
|
||||
});
|
||||
spyOn(collection, "create")
|
||||
view.save();
|
||||
expect(view.parse).wasCalled();
|
||||
expect(collection.create).wasCalledWith({fake: true});
|
||||
});
|
||||
|
||||
});
|
||||
}());
|
|
@ -1,106 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global EdgeShaper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
describe('Router', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
app = app || {};
|
||||
});
|
||||
|
||||
it('should bind itself to the app scope', function() {
|
||||
expect(app.router).toBeDefined();
|
||||
});
|
||||
|
||||
it('should display the welcome screen initially', function() {
|
||||
var renderMock;
|
||||
|
||||
runs(function() {
|
||||
//Navigate to somewhere, otherwise routing wont be triggered correctly.
|
||||
app.router.navigate("undef", {trigger: true});
|
||||
spyOn(app.router.welcome, "render");
|
||||
app.router.navigate("", {trigger: true});
|
||||
});
|
||||
|
||||
waits(1000);
|
||||
|
||||
runs(function() {
|
||||
expect(app.router.welcome.render).toHaveBeenCalled();
|
||||
window.history.back();
|
||||
window.history.back();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should react to routes for navigation', function() {
|
||||
|
||||
var renderMock;
|
||||
|
||||
runs(function() {
|
||||
|
||||
renderMock = {
|
||||
render: function(){}
|
||||
};
|
||||
|
||||
|
||||
spyOn(app, "ContentView").andCallFake(function(options) {
|
||||
var c = options.collection;
|
||||
expect(c.url).toEqual("content/Test");
|
||||
return renderMock;
|
||||
});
|
||||
spyOn(renderMock, "render");
|
||||
|
||||
|
||||
spyOn(app.router.navi, "render");
|
||||
|
||||
|
||||
app.router.navigate("/collection/Test", {trigger: true});
|
||||
});
|
||||
|
||||
waits(1000);
|
||||
|
||||
runs(function() {
|
||||
expect(app.ContentView).wasCalledWith({collection: jasmine.any(Backbone.Collection)});
|
||||
expect(renderMock.render).toHaveBeenCalled();
|
||||
expect(app.router.navi.render).wasCalledWith("Test");
|
||||
window.history.back();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}());
|
|
@ -1,77 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||
/*global beforeEach, afterEach */
|
||||
/*global describe, it, expect */
|
||||
/*global window, eb, loadFixtures, document */
|
||||
/*global $, _, d3*/
|
||||
/*global helper*/
|
||||
/*global EdgeShaper*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Graph functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
describe('Welcome View', function() {
|
||||
|
||||
var contentDiv;
|
||||
|
||||
beforeEach(function() {
|
||||
app = app || {};
|
||||
contentDiv = document.createElement("div");
|
||||
contentDiv.id = "content";
|
||||
document.body.appendChild(contentDiv);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
document.body.removeChild(contentDiv);
|
||||
});
|
||||
|
||||
it('should bind itself to the app scope', function() {
|
||||
expect(app.WelcomeView).toBeDefined();
|
||||
});
|
||||
|
||||
describe('checking display', function() {
|
||||
|
||||
it('should be able to display the welcome screen', function() {
|
||||
|
||||
runs(function() {
|
||||
var myView = new app.WelcomeView();
|
||||
myView.render();
|
||||
});
|
||||
|
||||
waits(1000);
|
||||
|
||||
runs(function() {
|
||||
expect($("#content #welcome").length).toEqual(1);
|
||||
expect($("#content #welcome").eq(0).text()).toEqual("Welcome");
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}());
|
|
@ -1,82 +0,0 @@
|
|||
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
||||
|
||||
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
|
||||
#HTMLReporter a { text-decoration: none; }
|
||||
#HTMLReporter a:hover { text-decoration: underline; }
|
||||
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
|
||||
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
|
||||
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#HTMLReporter .version { color: #aaaaaa; }
|
||||
#HTMLReporter .banner { margin-top: 14px; }
|
||||
#HTMLReporter .duration { color: #aaaaaa; float: right; }
|
||||
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
||||
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
|
||||
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
|
||||
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
|
||||
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
|
||||
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
|
||||
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
|
||||
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
||||
#HTMLReporter .runningAlert { background-color: #666666; }
|
||||
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
|
||||
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
|
||||
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
|
||||
#HTMLReporter .passingAlert { background-color: #a6b779; }
|
||||
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
|
||||
#HTMLReporter .failingAlert { background-color: #cf867e; }
|
||||
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
|
||||
#HTMLReporter .results { margin-top: 14px; }
|
||||
#HTMLReporter #details { display: none; }
|
||||
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .summary { display: none; }
|
||||
#HTMLReporter.showDetails #details { display: block; }
|
||||
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter .summary { margin-top: 14px; }
|
||||
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
|
||||
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
|
||||
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
|
||||
#HTMLReporter .description + .suite { margin-top: 0; }
|
||||
#HTMLReporter .suite { margin-top: 14px; }
|
||||
#HTMLReporter .suite a { color: #333333; }
|
||||
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
|
||||
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
|
||||
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
||||
#HTMLReporter .resultMessage span.result { display: block; }
|
||||
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
||||
|
||||
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
|
||||
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
|
||||
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
|
||||
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
|
||||
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
|
||||
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
|
||||
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
|
||||
#TrivialReporter .runner.running { background-color: yellow; }
|
||||
#TrivialReporter .options { text-align: right; font-size: .8em; }
|
||||
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
|
||||
#TrivialReporter .suite .suite { margin: 5px; }
|
||||
#TrivialReporter .suite.passed { background-color: #dfd; }
|
||||
#TrivialReporter .suite.failed { background-color: #fdd; }
|
||||
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
|
||||
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
|
||||
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
|
||||
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
|
||||
#TrivialReporter .spec.skipped { background-color: #bbb; }
|
||||
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
|
||||
#TrivialReporter .passed { background-color: #cfc; display: none; }
|
||||
#TrivialReporter .failed { background-color: #fbb; }
|
||||
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
|
||||
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
|
||||
#TrivialReporter .resultMessage .mismatch { color: black; }
|
||||
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
|
||||
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
|
||||
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
|
||||
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
|
|
@ -1,162 +0,0 @@
|
|||
(function() {
|
||||
"use strict";
|
||||
var FoxxApplication = require("org/arangodb/foxx").Application,
|
||||
app = new FoxxApplication();
|
||||
|
||||
app.registerRepository(
|
||||
"structs",
|
||||
{
|
||||
repository: "repositories/structures"
|
||||
}
|
||||
);
|
||||
|
||||
app.get('/list', function (req, res) {
|
||||
res.json(repositories.structs.getMonitored());
|
||||
})
|
||||
.nickname("list")
|
||||
.summary("List all.")
|
||||
.notes("Gets a List of all monitored collections.");
|
||||
|
||||
app.get('/structs/:name', function (req, res) {
|
||||
var name = req.params("name");
|
||||
res.json(repositories.structs.getStructs(name));
|
||||
})
|
||||
.nickname("structs")
|
||||
.pathParam("name", {
|
||||
description: "The name of a monitored collection",
|
||||
dataType: "string",
|
||||
required: true,
|
||||
multiple: false
|
||||
})
|
||||
.summary("Get Structs of collection")
|
||||
.notes("Gets the structural information of the given collection.");
|
||||
|
||||
app.get('/content/:name', function (req, res) {
|
||||
var name = req.params("name");
|
||||
res.json(repositories.structs.getContent(name));
|
||||
})
|
||||
.nickname("content")
|
||||
.summary("Get the content")
|
||||
.notes("Collects the complete content of one collection.");
|
||||
|
||||
//TODO!
|
||||
app.put("/content/:name/:key", function (req, res) {
|
||||
res.json({});
|
||||
});
|
||||
|
||||
//TODO!
|
||||
app.del("/content/:name/:key", function (req, res) {
|
||||
res.json();
|
||||
});
|
||||
|
||||
|
||||
//TODO!
|
||||
app.post("/content/:name/", function (req, res) {
|
||||
var content = JSON.parse(req.requestBody);
|
||||
var key = Math.floor(Math.random() * 100000);
|
||||
content._key = key;
|
||||
content._id = req.params("name") + "/" + key;
|
||||
content._rev = key;
|
||||
res.json(content);
|
||||
});
|
||||
|
||||
|
||||
app.get('/test/list', function (req, res) {
|
||||
res.json([{
|
||||
name: "String"
|
||||
},{
|
||||
name: "Number"
|
||||
}])
|
||||
})
|
||||
.nickname("test")
|
||||
.summary("Test List")
|
||||
.notes("Test for List");
|
||||
|
||||
|
||||
app.get('/test/structs/:name', function (req, res) {
|
||||
var name = req.params("name");
|
||||
switch(name) {
|
||||
case "String":
|
||||
res.json({
|
||||
attributes: {
|
||||
name : {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "Number":
|
||||
res.json({
|
||||
attributes: {
|
||||
int : {
|
||||
type: "number"
|
||||
},
|
||||
double: {
|
||||
type: "number"
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "All":
|
||||
res.json({
|
||||
attributes: {
|
||||
int : {
|
||||
type: "number"
|
||||
},
|
||||
double: {
|
||||
type: "number"
|
||||
},
|
||||
name : {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.json("Error has to be done!");
|
||||
}
|
||||
})
|
||||
.nickname("test")
|
||||
.summary("Test Structs")
|
||||
.notes("Test for Structs");
|
||||
|
||||
app.get('/test/content/:name', function (req, res) {
|
||||
var name = req.params("name");
|
||||
switch(name) {
|
||||
case "String":
|
||||
res.json([{
|
||||
_id: "String/1",
|
||||
_rev: "1",
|
||||
_key: "1",
|
||||
name: "Test"
|
||||
}]);
|
||||
break;
|
||||
case "Number":
|
||||
res.json([{
|
||||
_id: "Number/1",
|
||||
_rev: "1",
|
||||
_key: "1",
|
||||
int: 4,
|
||||
double: 4.5
|
||||
}]);
|
||||
break;
|
||||
case "All":
|
||||
res.json([{
|
||||
_id: "All/1",
|
||||
_rev: "1",
|
||||
_key: "1",
|
||||
int: 4,
|
||||
double: 4.5,
|
||||
name: "Test"
|
||||
}]);
|
||||
break;
|
||||
default:
|
||||
res.json("Error has to be done!");
|
||||
}
|
||||
})
|
||||
.nickname("test")
|
||||
.summary("Test Content")
|
||||
.notes("Test for Content");
|
||||
|
||||
app.start(applicationContext);
|
||||
}());
|
|
@ -1,70 +0,0 @@
|
|||
{
|
||||
"name": "arangoCMS",
|
||||
"version": "1.0.0",
|
||||
"description": "A Content Management System for ArangoDB",
|
||||
"thumbnail": "arangoLogo.png",
|
||||
|
||||
"apps": {
|
||||
"/": "cms.js"
|
||||
},
|
||||
|
||||
"lib": ".",
|
||||
|
||||
"assets": {
|
||||
"index.html": {
|
||||
"files": [
|
||||
"assets/index.html"
|
||||
]
|
||||
},
|
||||
|
||||
"test/test.html": {
|
||||
"files": [
|
||||
"assets/test/runner.html"
|
||||
]
|
||||
},
|
||||
|
||||
"app.js": {
|
||||
"files": [
|
||||
"assets/components/js/underscore/**",
|
||||
"assets/components/js/jquery/jquery.js",
|
||||
"assets/components/js/jquery/jquery.validate.min.js",
|
||||
"assets/components/js/backbone/**",
|
||||
"assets/components/js/bootstrap/**",
|
||||
"assets/components/js/ejs/**",
|
||||
"assets/js/models/**",
|
||||
"assets/js/collections/**",
|
||||
"assets/js/views/**",
|
||||
"assets/js/routers/**"
|
||||
]
|
||||
},
|
||||
|
||||
"test/test.js": {
|
||||
"files": [
|
||||
"assets/test/lib/jasmine.js",
|
||||
"assets/test/lib/jasmine-html.js",
|
||||
"assets/test/specs/**"
|
||||
]
|
||||
},
|
||||
|
||||
"style.css": {
|
||||
"files": [
|
||||
"assets/bootstrap.css",
|
||||
"assets/style.css"
|
||||
]
|
||||
},
|
||||
|
||||
"test/style.css": {
|
||||
"files": [
|
||||
"assets/bootstrap.css",
|
||||
"assets/test/style/style.css"
|
||||
]
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"files": {
|
||||
"templates": "assets/templates",
|
||||
"test/templates": "assets/templates",
|
||||
"img": "assets/bootstrap/glyphicons"
|
||||
}
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true, unparam: true */
|
||||
/*global require, exports*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief A TODO-List Foxx-Application written for ArangoDB
|
||||
///
|
||||
/// @file This Document represents the repository communicating with ArangoDB
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2013 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Michael Hackstein
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var _ = require("underscore"),
|
||||
Foxx = require("org/arangodb/foxx"),
|
||||
structures = require("internal").db._collection("_structures"); // TODO!
|
||||
exports.Repository = Foxx.Repository.extend({
|
||||
// Define the save functionality
|
||||
getMonitored: function () {
|
||||
return [{
|
||||
name: "String"
|
||||
},{
|
||||
name: "Number"
|
||||
}];
|
||||
/*
|
||||
var a = structures.all(),
|
||||
res = [];
|
||||
while (a.hasNext()) {
|
||||
res.push({
|
||||
name: a.next().collection
|
||||
});
|
||||
}
|
||||
return res;
|
||||
*/
|
||||
},
|
||||
|
||||
getStructs: function (name) {
|
||||
switch(name) {
|
||||
case "String":
|
||||
return {
|
||||
attributes: {
|
||||
name : {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case "Number":
|
||||
return {
|
||||
attributes: {
|
||||
int : {
|
||||
type: "number"
|
||||
},
|
||||
double: {
|
||||
type: "number"
|
||||
},
|
||||
boolean: {
|
||||
type: "boolean"
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case "All":
|
||||
return {
|
||||
attributes: {
|
||||
int : {
|
||||
type: "number"
|
||||
},
|
||||
double: {
|
||||
type: "number"
|
||||
},
|
||||
name : {
|
||||
type: "string"
|
||||
},
|
||||
boolean: {
|
||||
type: "boolean"
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
default:
|
||||
res.json("Error has to be done!");
|
||||
}
|
||||
/*
|
||||
return structures.firstExample({collection: name});
|
||||
*/
|
||||
},
|
||||
|
||||
getContent: function (name) {
|
||||
switch(name) {
|
||||
case "String":
|
||||
return [{
|
||||
_id: "String/1",
|
||||
_rev: "1",
|
||||
_key: "1",
|
||||
name: "Test"
|
||||
}];
|
||||
case "Number":
|
||||
return [{
|
||||
_id: "Number/1",
|
||||
_rev: "1",
|
||||
_key: "1",
|
||||
int: 4,
|
||||
double: 4.5,
|
||||
boolean: true
|
||||
}];
|
||||
case "All":
|
||||
return [{
|
||||
_id: "All/1",
|
||||
_rev: "1",
|
||||
_key: "1",
|
||||
int: 4,
|
||||
double: 4.5,
|
||||
name: "Test",
|
||||
boolean: true
|
||||
}];
|
||||
default:
|
||||
return "Error has to be done!";
|
||||
}
|
||||
/*
|
||||
var db = require("internal").db._collection(name);
|
||||
// TODO: Requires Optimization!
|
||||
return db.toArray();
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
Loading…
Reference in New Issue