aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/menu
diff options
context:
space:
mode:
authorkborchers <k_borchers@yahoo.com>2011-09-14 10:29:36 -0500
committerkborchers <k_borchers@yahoo.com>2011-09-14 10:29:36 -0500
commit9e617bbad1df4a2bc8c743b52bced66f31c86a80 (patch)
tree22e9c3b1cb1f5eab21b9ad1ff8d1c3deab8dc6da /tests/unit/menu
parentcedac75bccbfd8eb2b0301fd40fc31a36a9296b1 (diff)
downloadjquery-ui-9e617bbad1df4a2bc8c743b52bced66f31c86a80.tar.gz
jquery-ui-9e617bbad1df4a2bc8c743b52bced66f31c86a80.zip
Menu: Add support for structures other than UL/LI plus visual and unit tests
Diffstat (limited to 'tests/unit/menu')
-rw-r--r--tests/unit/menu/menu.html38
-rw-r--r--tests/unit/menu/menu_defaults.js1
-rw-r--r--tests/unit/menu/menu_events.js57
-rw-r--r--tests/unit/menu/menu_test_helpers.js4
4 files changed, 98 insertions, 2 deletions
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html
index dc5b71a00..014123144 100644
--- a/tests/unit/menu/menu.html
+++ b/tests/unit/menu/menu.html
@@ -207,6 +207,44 @@
<li class="foo"><a class="foo" href="#">Amesville</a></li>
</ul>
+<div id="menu5">
+ <blockquote><a href="#">Aberdeen</a></blockquote>
+ <blockquote><a href="#">Ada</a></blockquote>
+ <blockquote><a href="#">Adamsville</a></blockquote>
+ <blockquote><a href="#">Addyston</a></blockquote>
+ <blockquote>
+ <a href="#">Delphi</a>
+ <div>
+ <blockquote><a href="#">Ada</a></blockquote>
+ <blockquote><a href="#">Saarland</a></blockquote>
+ <blockquote><a href="#">Salzburg</a></blockquote>
+ </div>
+ </blockquote>
+ <blockquote><a href="#">Saarland</a></blockquote>
+ <blockquote>
+ <a href="#">Salzburg</a>
+ <div>
+ <blockquote>
+ <a href="#">Delphi</a>
+ <div>
+ <blockquote><a href="#">Ada</a></blockquote>
+ <blockquote><a href="#">Saarland</a></blockquote>
+ <blockquote><a href="#">Salzburg</a></blockquote>
+ </div>
+ </blockquote>
+ <blockquote>
+ <a href="#">Delphi</a>
+ <div>
+ <blockquote><a href="#">Ada</a></blockquote>
+ <blockquote><a href="#">Saarland</a></blockquote>
+ <blockquote><a href="#">Salzburg</a></blockquote>
+ </div>
+ </blockquote>
+ <blockquote><a href="#">Perch</a></blockquote>
+ </div>
+ </blockquote>
+</div>
+
<div id="log"></div>
</div>
diff --git a/tests/unit/menu/menu_defaults.js b/tests/unit/menu/menu_defaults.js
index dd182ca09..1756e4648 100644
--- a/tests/unit/menu/menu_defaults.js
+++ b/tests/unit/menu/menu_defaults.js
@@ -5,6 +5,7 @@ commonWidgetTests( "menu", {
my: "left top",
at: "right top"
},
+ items: "ul",
// callbacks
create: null
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({
diff --git a/tests/unit/menu/menu_test_helpers.js b/tests/unit/menu/menu_test_helpers.js
index 717cfc45d..052c9226b 100644
--- a/tests/unit/menu/menu_test_helpers.js
+++ b/tests/unit/menu/menu_test_helpers.js
@@ -10,5 +10,5 @@ function menu_log( message, clear ) {
function menu_click( menu, item ) {
$( "#log" ).data( "lastItem", item );
- menu.find( "li:eq(" + item + ") a" ).trigger( "click" );
-}
+ menu.children( ":eq(" + item + ")" ).find( "a:first" ).trigger( "click" );
+} \ No newline at end of file