aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/menu/menu_events.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/menu/menu_events.js')
-rw-r--r--tests/unit/menu/menu_events.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js
index 563ed7c2d..6d1b02b87 100644
--- a/tests/unit/menu/menu_events.js
+++ b/tests/unit/menu/menu_events.js
@@ -21,6 +21,23 @@ test("handle click on menu", function() {
equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
});
+test("handle click on custom item menu", function() {
+ expect(1);
+ var ac = $('#menu5').menu({
+ select: function(event, ui) {
+ menu_log();
+ },
+ items: "div"
+ });
+ menu_log("click",true);
+ menu_click($('#menu5'),"1");
+ menu_log("afterclick");
+ menu_click( ac,"2");
+ menu_click($('#menu5'),"3");
+ menu_click( ac,"1");
+ equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
+});
+
test( "handle blur: click", function() {
expect( 4 );
var $menu = $( "#menu1" ).menu({
@@ -41,6 +58,27 @@ test( "handle blur: click", function() {
$("#remove").remove();
});
+test( "handle blur on custom item menu: click", function() {
+ expect( 4 );
+ var $menu = $( "#menu5" ).menu({
+ focus: function( event, ui ) {
+ equal( event.originalEvent.type, "click", "focus triggered 'click'" );
+ equal( event.type, "menufocus", "focus event.type is 'menufocus'" );
+
+ },
+ blur: function( event, ui ) {
+ equal( event.originalEvent.type, "click", "blur triggered 'click'" );
+ equal( event.type, "menublur", "blur event.type is 'menublur'" );
+ },
+ items: "div"
+ });
+
+ menu_click($('#menu5'),"1");
+ $( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" );
+
+ $("#remove").remove();
+});
+
asyncTest( "handle submenu auto collapse: mouseleave", function() {
expect( 4 );
var $menu = $( "#menu2" ).menu();
@@ -60,6 +98,25 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
}, 200);
});
+asyncTest( "handle custom menu item submenu auto collapse: mouseleave", function() {
+ expect( 4 );
+ var $menu = $( "#menu5" ).menu( { items: "div" } );
+
+ $menu.children( ":nth-child(7)" ).trigger( "mouseover" );
+ setTimeout(function() {
+ equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "first submenu expanded" );
+ $menu.children( ":nth-child(7)" ).find( "div:first" ).children( ":first" ).trigger( "mouseover" );
+ setTimeout(function() {
+ equal( $menu.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" );
+ $menu.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" );
+ equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
+ $menu.trigger( "mouseleave" );
+ equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
+ start();
+ }, 400);
+ }, 200);
+});
+
test("handle keyboard navigation on menu without scroll and without submenus", function() {
expect(12);
var element = $('#menu1').menu({