mirror of https://gitee.com/bigwinds/arangodb
Increased test coverage of new foxx views. All positive pathes are now covered. Error handling not yet
This commit is contained in:
parent
adbb956b6f
commit
6ba7bf6918
|
@ -15,12 +15,12 @@
|
||||||
comparator: function(item, item2) {
|
comparator: function(item, item2) {
|
||||||
var a, b;
|
var a, b;
|
||||||
if (this.sortOptions.desc === true) {
|
if (this.sortOptions.desc === true) {
|
||||||
a = item.get('name');
|
a = item.get('mount');
|
||||||
b = item2.get('name');
|
b = item2.get('mount');
|
||||||
return a < b ? 1 : a > b ? -1 : 0;
|
return a < b ? 1 : a > b ? -1 : 0;
|
||||||
}
|
}
|
||||||
a = item.get('name');
|
a = item.get('mount');
|
||||||
b = item2.get('name');
|
b = item2.get('mount');
|
||||||
return a > b ? 1 : a < b ? -1 : 0;
|
return a > b ? 1 : a < b ? -1 : 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleDevelopment: function() {
|
toggleDevelopment: function() {
|
||||||
this.model.toggleDevelopment(!this.model.get("development"), function() {
|
this.model.toggleDevelopment(!this.model.isDevelopment(), function() {
|
||||||
if (this.model.get("development")) {
|
if (this.model.isDevelopment()) {
|
||||||
$("#app-switch-mode").val("Production");
|
$("#app-switch-mode").val("Production");
|
||||||
$("#app-development-indicator").css("display", "inline");
|
$("#app-development-indicator").css("display", "inline");
|
||||||
} else {
|
} else {
|
||||||
|
@ -143,6 +143,14 @@
|
||||||
msg: "Has to be an integer."
|
msg: "Has to be an integer."
|
||||||
}];
|
}];
|
||||||
/* falls through */
|
/* falls through */
|
||||||
|
case "number":
|
||||||
|
if (check === undefined) {
|
||||||
|
check = [{
|
||||||
|
rule: Joi.number().optional().allow(""),
|
||||||
|
msg: "Has to be a number."
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
/* falls through */
|
||||||
default:
|
default:
|
||||||
if (check === undefined) {
|
if (check === undefined) {
|
||||||
check = [{
|
check = [{
|
||||||
|
|
|
@ -22,17 +22,17 @@
|
||||||
toggle: function(type, shouldShow) {
|
toggle: function(type, shouldShow) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "devel":
|
case "devel":
|
||||||
if (this.model.get("development") === true) {
|
if (this.model.isDevelopment()) {
|
||||||
this._show = shouldShow;
|
this._show = shouldShow;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "production":
|
case "production":
|
||||||
if (this.model.get("development") === false && this.model.get("system") === false) {
|
if (!this.model.isDevelopment() && !this.model.isSystem()) {
|
||||||
this._show = shouldShow;
|
this._show = shouldShow;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "system":
|
case "system":
|
||||||
if (this.model.get("system") === true) {
|
if (this.model.isSystem()) {
|
||||||
this._show = shouldShow;
|
this._show = shouldShow;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
{ "pattern": "clusterFrontend/js/templates/*.ejs", "served": true, "included": false, "watched": true},
|
{ "pattern": "clusterFrontend/js/templates/*.ejs", "served": true, "included": false, "watched": true},
|
||||||
"frontend/js/lib/jquery-2.1.0.min.js",
|
"frontend/js/lib/jquery-2.1.0.min.js",
|
||||||
"test/mocks/overwriteAjax.js",
|
"test/mocks/overwriteAjax.js",
|
||||||
|
"test/mocks/createDummy.js",
|
||||||
"frontend/js/lib/jquery-ui-1.9.2.custom.js",
|
"frontend/js/lib/jquery-ui-1.9.2.custom.js",
|
||||||
"frontend/js/lib/jquery.autogrow.js",
|
"frontend/js/lib/jquery.autogrow.js",
|
||||||
"frontend/js/lib/jquery.jeditable.js",
|
"frontend/js/lib/jquery.jeditable.js",
|
||||||
|
@ -248,6 +249,7 @@
|
||||||
|
|
||||||
"test/specs/views/apiViewSpec.js",
|
"test/specs/views/apiViewSpec.js",
|
||||||
"test/specs/views/applicationsViewSpec.js",
|
"test/specs/views/applicationsViewSpec.js",
|
||||||
|
"test/specs/views/applicationDetailViewSpec.js",
|
||||||
"test/specs/views/modalViewSpec.js",
|
"test/specs/views/modalViewSpec.js",
|
||||||
"test/specs/views/editListEntryViewSpec.js",
|
"test/specs/views/editListEntryViewSpec.js",
|
||||||
"test/specs/views/collectionsViewSpec.js",
|
"test/specs/views/collectionsViewSpec.js",
|
||||||
|
|
|
@ -30,6 +30,34 @@
|
||||||
expect(col.url).toEqual("/_admin/aardvark/foxxes");
|
expect(col.url).toEqual("/_admin/aardvark/foxxes");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("sorting apps", function() {
|
||||||
|
var first, second, third;
|
||||||
|
beforeEach(function() {
|
||||||
|
first = "/_test";
|
||||||
|
second = "/aal";
|
||||||
|
third = "/zztop";
|
||||||
|
col.add({mount: second});
|
||||||
|
col.add({mount: third});
|
||||||
|
col.add({mount: first});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should always be by mount", function() {
|
||||||
|
col.sort();
|
||||||
|
expect(col.models[0].get("mount")).toEqual(first);
|
||||||
|
expect(col.models[1].get("mount")).toEqual(second);
|
||||||
|
expect(col.models[2].get("mount")).toEqual(third);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be by mount and reversable", function() {
|
||||||
|
col.setSortingDesc(true);
|
||||||
|
col.sort();
|
||||||
|
expect(col.models[2].get("mount")).toEqual(first);
|
||||||
|
expect(col.models[1].get("mount")).toEqual(second);
|
||||||
|
expect(col.models[0].get("mount")).toEqual(third);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe("installing apps", function() {
|
describe("installing apps", function() {
|
||||||
|
|
||||||
it("should generate an app", function() {
|
it("should generate an app", function() {
|
||||||
|
|
|
@ -194,6 +194,131 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("with different configuration types", function() {
|
||||||
|
var valid1, valid3, valid4, def;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
runs(function() {
|
||||||
|
valid1 = "Value";
|
||||||
|
valid3 = "4.5";
|
||||||
|
valid4 = "4";
|
||||||
|
def = "default";
|
||||||
|
|
||||||
|
config.data.opt1 = {
|
||||||
|
type: "string",
|
||||||
|
description: "My String"
|
||||||
|
};
|
||||||
|
config.data.opt2 = {
|
||||||
|
type: "boolean",
|
||||||
|
description: "My Bool"
|
||||||
|
};
|
||||||
|
config.data.opt3 = {
|
||||||
|
type: "number",
|
||||||
|
description: "My Number"
|
||||||
|
};
|
||||||
|
config.data.opt4 = {
|
||||||
|
type: "integer",
|
||||||
|
description: "My Integer"
|
||||||
|
};
|
||||||
|
config.data.opt5 = {
|
||||||
|
type: "string",
|
||||||
|
description: "My String",
|
||||||
|
default: def
|
||||||
|
};
|
||||||
|
view.render();
|
||||||
|
$(buttonId).click();
|
||||||
|
});
|
||||||
|
|
||||||
|
waitsFor(function () {
|
||||||
|
return $("#modal-dialog").css("display") === "block";
|
||||||
|
}, "The configure App dialog should be shown", 750);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not allow to configure if the string is empty", function() {
|
||||||
|
$("#app_config_opt1").val("");
|
||||||
|
$("#app_config_opt3").val(valid3);
|
||||||
|
$("#app_config_opt4").val(valid4);
|
||||||
|
$("#app_config_opt4").keyup();
|
||||||
|
expect($("#modalButton1").prop("disabled")).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not allow to configure if the number is empty", function() {
|
||||||
|
$("#app_config_opt1").val(valid1);
|
||||||
|
$("#app_config_opt3").val("");
|
||||||
|
$("#app_config_opt4").val(valid4);
|
||||||
|
$("#app_config_opt4").keyup();
|
||||||
|
expect($("#modalButton1").prop("disabled")).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not allow to configure if the number is invalid", function() {
|
||||||
|
$("#app_config_opt1").val(valid1);
|
||||||
|
$("#app_config_opt3").val("invalid");
|
||||||
|
$("#app_config_opt4").val(valid4);
|
||||||
|
$("#app_config_opt4").keyup();
|
||||||
|
expect($("#modalButton1").prop("disabled")).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not allow to configure if the integer is empty", function() {
|
||||||
|
$("#app_config_opt1").val(valid1);
|
||||||
|
$("#app_config_opt3").val(valid3);
|
||||||
|
$("#app_config_opt4").val("");
|
||||||
|
$("#app_config_opt4").keyup();
|
||||||
|
expect($("#modalButton1").prop("disabled")).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not allow to configure if the integer is invalid", function() {
|
||||||
|
$("#app_config_opt1").val(valid1);
|
||||||
|
$("#app_config_opt3").val(valid3);
|
||||||
|
$("#app_config_opt4").val("invalid");
|
||||||
|
$("#app_config_opt4").keyup();
|
||||||
|
expect($("#modalButton1").prop("disabled")).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not allow to configure if the integer is not integer", function() {
|
||||||
|
$("#app_config_opt1").val(valid1);
|
||||||
|
$("#app_config_opt3").val(valid3);
|
||||||
|
$("#app_config_opt4").val("4.5");
|
||||||
|
$("#app_config_opt4").keyup();
|
||||||
|
expect($("#modalButton1").prop("disabled")).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should allow to configure if all values are valid", function() {
|
||||||
|
runs(function() {
|
||||||
|
$("#app_config_opt1").val(valid1);
|
||||||
|
$("#app_config_opt3").val(valid3);
|
||||||
|
$("#app_config_opt4").val(valid4);
|
||||||
|
$("#app_config_opt4").keyup();
|
||||||
|
expect($("#modalButton1").prop("disabled")).toBeFalsy();
|
||||||
|
spyOn(appDummy, "setConfiguration").andCallFake(function(data, callback) {
|
||||||
|
callback({
|
||||||
|
error: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$("#modalButton1").click();
|
||||||
|
});
|
||||||
|
|
||||||
|
waitsFor(function () {
|
||||||
|
return $("#modal-dialog").css("display") === "none";
|
||||||
|
}, "The configure App dialog should be hidden.", 750);
|
||||||
|
|
||||||
|
runs(function() {
|
||||||
|
expect(appDummy.setConfiguration).toHaveBeenCalledWith(
|
||||||
|
{
|
||||||
|
opt1: valid1,
|
||||||
|
opt2: false,
|
||||||
|
opt3: 4.5,
|
||||||
|
opt4: 4,
|
||||||
|
opt5: def
|
||||||
|
},
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("if not required", function() {
|
describe("if not required", function() {
|
||||||
|
@ -207,6 +332,9 @@
|
||||||
|
|
||||||
it("the button should be disabled", function() {
|
it("the button should be disabled", function() {
|
||||||
expect($(buttonId).hasClass("disabled")).toEqual(true);
|
expect($(buttonId).hasClass("disabled")).toEqual(true);
|
||||||
|
spyOn(window.modalView, "show");
|
||||||
|
$(buttonId).click();
|
||||||
|
expect(window.modalView.show).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue