1
0
Fork 0

100% coverage of navigationView

This commit is contained in:
Heiko Kernbach 2014-05-06 14:45:43 +02:00
parent 8f821d62fe
commit e5139f3e84
3 changed files with 156 additions and 8 deletions

View File

@ -85,13 +85,12 @@
},
handleSelectNavigation: function () {
$("#arangoCollectionSelect").change(function () {
var navigateTo = $(this).find("option:selected").val();
window.App.navigate(navigateTo, {trigger: true});
var self = this;
$("#arangoCollectionSelect").change(function() {
self.navigateBySelect();
});
},
selectMenuItem: function (menuItem) {
$('.navlist li').removeClass('active');
if (menuItem) {

View File

@ -501,5 +501,34 @@
expect($.fn.click).toHaveBeenCalled();
});
/*it("test focused button navigation (direction right)", function() {
testee.enabledHotkey = false;
var btnObj = {},
title = "Save",
buttons = [],
cbs = {
callback: function() {
}
},
btn,
testShow = testee.show.bind(testee, "modalTable.ejs", "My Modal");
spyOn(cbs, "callback").andCallThrough();
btnObj = testee.createSuccessButton(title, cbs.callback);
buttons.push(btnObj);
testShow(buttons);
btn = $(".button-" + btnObj.type, $(div));
spyOn($.fn, "next");
spyOn($.fn, "is").andReturn(true);
btn.focus();
testee.navigateThroughButtons('right');
expect($.fn.next).toHaveBeenCalled();
console.log(testee);
});*/
});
}());

View File

@ -79,7 +79,7 @@
beforeEach(function() {
view = new window.NavigationView(
{userCollection : UserCollectionDummy, currentDB : window.currentDB}
{userCollection : UserCollectionDummy, currentDB : window.currentDB}
);
view.render();
});
@ -127,13 +127,132 @@
expect(window.App.navigate).toHaveBeenCalledWith("graph", {trigger: true});
});
it("should handle selected database render", function() {
spyOn(view.dbSelectionView, "render");
view.handleSelectDatabase();
expect(view.dbSelectionView.render).toHaveBeenCalled();
});
it("should navigate to the selected value from options div", function() {
var toNavigate = "#collections"
$("#arangoCollectionSelect").val(toNavigate);
view.navigateBySelect();
expect(window.App.navigate).toHaveBeenCalledWith(toNavigate, {trigger: true});
});
it("should navigate automatic to the selected value from options div", function() {
spyOn($.fn, "change").andCallFake(function(a){
a();
});
spyOn(view, "navigateBySelect");
view.handleSelectNavigation();
expect($.fn.change).toHaveBeenCalledWith(jasmine.any(Function));
expect(view.navigateBySelect).toHaveBeenCalled();
});
it("should render selectMenuItems correctly", function() {
var entry = "tools-menu";
view.selectMenuItem(entry);
var toBeActiveClass = $('.' + entry);
var toBeFalseClass1 = $('.' + "graphviewer-menu");
var toBeFalseClass2 = $('.' + "databases-menu");
var toBeFalseClass3 = $('.' + "query-menu");
var toBeFalseClass4 = $('.' + "collections-menu");
var toBeFalseClass5 = $('.' + "applications-menu");
expect(toBeActiveClass.hasClass("active")).toBeTruthy();
expect(toBeFalseClass1.hasClass("active")).toBeFalsy();
expect(toBeFalseClass2.hasClass("active")).toBeFalsy();
expect(toBeFalseClass3.hasClass("active")).toBeFalsy();
expect(toBeFalseClass4.hasClass("active")).toBeFalsy();
expect(toBeFalseClass5.hasClass("active")).toBeFalsy();
});
it("should show dropdown for menu item: links", function() {
var e = {
target: {
id: "links"
}
};
spyOn($.fn, "show");
view.showDropdown(e);
expect($.fn.show).toHaveBeenCalledWith(200);
});
it("should show dropdown for menu item: tools", function() {
var e = {
target: {
id: "tools"
}
};
spyOn($.fn, "show");
view.showDropdown(e);
expect($.fn.show).toHaveBeenCalledWith(200);
});
it("should show dropdown for menu item: dbselection", function() {
var e = {
target: {
id: "dbselection"
}
};
spyOn($.fn, "show");
view.showDropdown(e);
expect($.fn.show).toHaveBeenCalledWith(200);
});
it("should hide dropdown for menu item: linkDropdown", function() {
spyOn($.fn, "hide");
$('#linkDropdown').mouseenter().mouseleave();
expect($.fn.hide).toHaveBeenCalled();
});
it("should hide dropdown for menu item: toolsDropdown", function() {
spyOn($.fn, "hide");
$('#toolsDropdown').mouseenter().mouseleave();
expect($.fn.hide).toHaveBeenCalled();
});
it("should hide dropdown for menu item: dbSelect", function() {
spyOn($.fn, "hide");
$('#dbSelect').mouseenter().mouseleave();
expect($.fn.hide).toHaveBeenCalled();
});
it("should navigateByTab: tools", function() {
spyOn($.fn, "slideToggle");
$('#tools').click();
expect($.fn.slideToggle).toHaveBeenCalled();
});
it("should navigateByTab: links", function() {
spyOn($.fn, "slideToggle");
$('#links').click();
expect($.fn.slideToggle).toHaveBeenCalled();
});
it("should navigateByTab: dbSelection", function() {
$('#tools').attr("id", "dbselection");
spyOn($.fn, "slideToggle");
$('#dbselection').click();
expect($.fn.slideToggle).toHaveBeenCalled();
$('#dbselection').attr("id", "tools");
});
it("should navigateByTab: blank", function() {
$('#tools').attr("id", "");
$('#links').attr("id", "");
spyOn($.fn, "attr");
$('.tab').click();
expect($.fn.attr).toHaveBeenCalled();
});
});
describe("in _system database", function() {
beforeEach(function() {
view = new window.NavigationView(
{userCollection : UserCollectionDummy, currentDB : window.currentDB}
{userCollection : UserCollectionDummy, currentDB : window.currentDB}
);
view.render();
});
@ -152,11 +271,11 @@
curName = "firstDB";
isSystem = false;
view = new window.NavigationView(
{userCollection : UserCollectionDummy, currentDB : window.currentDB}
{userCollection : UserCollectionDummy, currentDB : window.currentDB}
);
view.render();
});
it("should not offer a logs tab", function() {
var tab = $("#logs", $(div));
expect(tab.length).toEqual(0);
@ -165,4 +284,5 @@
});
}());