diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-06-28 05:38:08 -0700 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-06-28 05:38:08 -0700 |
commit | 25d5aa1fa1c92eebccbacba6f5149a33389c4d23 (patch) | |
tree | ca4715f05413592d7c5334b8fd756be043392d07 /tests | |
parent | 5ae668fdb61dd5e516dc599166a31fd46a916bfd (diff) | |
download | jquery-ui-25d5aa1fa1c92eebccbacba6f5149a33389c4d23.tar.gz jquery-ui-25d5aa1fa1c92eebccbacba6f5149a33389c4d23.zip |
Menu tests: Split out markup structure and accessibility assertions.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/menu/menu_core.js | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js index ee737ceb1..5ee28c14a 100644 --- a/tests/unit/menu/menu_core.js +++ b/tests/unit/menu/menu_core.js @@ -2,23 +2,29 @@ module( "menu: core" ); +test( "markup structure", function() { + expect( 6 ); + var element = $( "#menu1" ).menu(); + ok( element.hasClass( "ui-menu" ), "main element is .ui-menu" ); + element.children().each(function( index ) { + ok( $( this ).hasClass( "ui-menu-item" ), "child " + index + " is .ui-menu-item" ); + }); +}); + test( "accessibility", function () { - expect( 5 ); - var item, - element = $( "#menu1" ).menu(), - item0 = $( "li:eq(0) a" ); + expect( 4 ); + var element = $( "#menu1" ).menu(); - ok( element.hasClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ), "menu class"); equal( element.attr( "role" ), "menu", "main role" ); - ok( !element.attr( "aria-activedescendant" ), "aria attribute not yet active" ); + ok( !element.attr( "aria-activedescendant" ), "aria-activedescendant not set" ); + + element.menu( "focus", $.Event(), element.children().eq( -2 ) ); + equal( element.attr( "aria-activedescendant" ), "testID1", "aria-activedescendant from existing id" ); - item = element.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end(); - element.menu( "focus", $.Event(), item ); - equal( element.attr( "aria-activedescendant" ), "xid", "aria attribute, id from DOM" ); + element.menu( "focus", $.Event(), element.children().eq( 0 ) ); + ok( /^ui-id-\d+$/.test( element.attr( "aria-activedescendant" ) ), "aria-activedescendant from generated id" ); - item = element.find( "li:last" ); - element.menu( "focus", $.Event(), item ); - ok( /^ui-id-\d+$/.test( element.attr( "aria-activedescendant" ) ), "aria attribute, generated id"); + // Item roles are tested in the role option tests }); })( jQuery ); |