mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Menu Tests: Remove unused unit tests and add new unit tests to improve coverage.
This commit is contained in:
parent
c1dc1911bf
commit
c275ebe09b
@ -63,7 +63,7 @@
|
||||
<li class="foo"><a class="foo" href="#">Aberdeen</a></li>
|
||||
<li class="foo"><a class="foo" href="#">Ada</a></li>
|
||||
<li class="foo"><a class="foo" href="#">Adamsville</a></li>
|
||||
<li class="foo"><a class="foo" href="#">Addyston</a></li>
|
||||
<li class="foo"><a class="foo" href="#"><span class="ui-icon ui-icon-print"></span>Addyston</a></li>
|
||||
<li>
|
||||
<a href="#">Delphi</a>
|
||||
<ul>
|
||||
|
@ -41,50 +41,63 @@ test("handle click on custom item menu", function() {
|
||||
equal( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
|
||||
});
|
||||
|
||||
/* Commenting out these tests until a way to handle the extra focus and blur events
|
||||
fired by IE is found
|
||||
test( "handle blur: click", function() {
|
||||
expect( 4 );
|
||||
var $menu = $( "#menu1" ).menu({
|
||||
focus: function( event, ui ) {
|
||||
equal( event.originalEvent.type, "click", "focus triggered 'click'" );
|
||||
equal( event.type, "menufocus", "focus event.type is 'menufocus'" );
|
||||
asyncTest( "handle blur", function() {
|
||||
expect( 1 );
|
||||
var blurHandled = false,
|
||||
$menu = $( "#menu1" ).menu({
|
||||
blur: function( event, ui ) {
|
||||
// Ignore duplicate blur event fired by IE
|
||||
if ( !blurHandled ) {
|
||||
blurHandled = true;
|
||||
equal( event.type, "menublur", "blur event.type is 'menublur'" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
blur: function( event, ui ) {
|
||||
equal( event.originalEvent.type, "click", "blur triggered 'click'" );
|
||||
equal( event.type, "menublur", "blur event.type is 'menublur'" );
|
||||
click( $menu, "1" );
|
||||
setTimeout( function() {
|
||||
$menu.blur();
|
||||
start();
|
||||
}, 350);
|
||||
});
|
||||
|
||||
asyncTest( "handle blur on click", function() {
|
||||
expect( 1 );
|
||||
var blurHandled = false,
|
||||
$menu = $( "#menu1" ).menu({
|
||||
blur: function( event, ui ) {
|
||||
// Ignore duplicate blur event fired by IE
|
||||
if ( !blurHandled ) {
|
||||
blurHandled = true;
|
||||
equal( event.type, "menublur", "blur event.type is 'menublur'" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
click( $menu, "1" );
|
||||
setTimeout( function() {
|
||||
$( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" );
|
||||
$("#remove").remove();
|
||||
start();
|
||||
}, 350);
|
||||
});
|
||||
|
||||
test( "handle focus of menu with active item", function() {
|
||||
expect( 1 );
|
||||
var element = $( "#menu1" ).menu({
|
||||
focus: function( event, ui ) {
|
||||
log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
|
||||
}
|
||||
});
|
||||
|
||||
$menu.find( "li a:first" ).trigger( "click" );
|
||||
$( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" );
|
||||
|
||||
$("#remove").remove();
|
||||
log( "focus", true );
|
||||
element.focus();
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
element.focus();
|
||||
equal( $("#log").html(), "2,2,1,0,focus,", "current active item remains active");
|
||||
});
|
||||
|
||||
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"
|
||||
});
|
||||
|
||||
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(),
|
||||
@ -536,4 +549,42 @@ asyncTest("handle keyboard navigation and mouse click on menu with disabled item
|
||||
}
|
||||
});
|
||||
|
||||
test("handle keyboard navigation with spelling of menu items", function() {
|
||||
expect( 2 );
|
||||
var element = $( "#menu2" ).menu({
|
||||
focus: function( event, ui ) {
|
||||
log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
|
||||
}
|
||||
});
|
||||
|
||||
log( "keydown", true );
|
||||
element.one( "menufocus", function( event, ui ) {
|
||||
element.simulate( "keydown", { keyCode: 65 } );
|
||||
element.simulate( "keydown", { keyCode: 68 } );
|
||||
element.simulate( "keydown", { keyCode: 68 } );
|
||||
equal( $("#log").html(), "3,1,0,keydown,", "Keydown focus Addyston by spelling the first 3 letters");
|
||||
element.simulate( "keydown", { keyCode: 68 } );
|
||||
equal( $("#log").html(), "4,3,1,0,keydown,", "Keydown focus Delphi by repeating the 'd' again");
|
||||
});
|
||||
element.focus();
|
||||
});
|
||||
|
||||
asyncTest("handle page up and page down before the menu has focus", function() {
|
||||
expect( 1 );
|
||||
var element = $( "#menu1" ).menu({
|
||||
focus: function( event, ui ) {
|
||||
log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
|
||||
}
|
||||
});
|
||||
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||
element.blur();
|
||||
setTimeout( function() {
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||
equal( $("#log").html(), "0,0,keydown,", "Page Up and Page Down bring initial focus to first item");
|
||||
start();
|
||||
}, 350);
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
Loading…
Reference in New Issue
Block a user