diff options
author | Scott González <scott.gonzalez@gmail.com> | 2015-04-07 10:55:52 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2015-04-09 09:27:00 -0400 |
commit | bde431bb449b1d957d4e0b736111ff342f2a919d (patch) | |
tree | 27fd40037c30dbff8ef3b6113e90817ab96b53bf /tests/unit/menu/core.js | |
parent | dc4b015a8b9acdb5bff2d5dd89737b3d8b64097f (diff) | |
download | jquery-ui-bde431bb449b1d957d4e0b736111ff342f2a919d.tar.gz jquery-ui-bde431bb449b1d957d4e0b736111ff342f2a919d.zip |
Tests: Rename files
Ref gh-1528
Diffstat (limited to 'tests/unit/menu/core.js')
-rw-r--r-- | tests/unit/menu/core.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/unit/menu/core.js b/tests/unit/menu/core.js new file mode 100644 index 000000000..08644c31f --- /dev/null +++ b/tests/unit/menu/core.js @@ -0,0 +1,76 @@ +define( [ + "jquery", + "./helper", + "ui/menu" +], function( $, testHelper ) { + +module( "menu: core" ); + +test( "markup structure", function( assert ) { + expect( 11 ); + var element = $( "#menu9" ).menu(), + items = element.children(), + firstItemChildren = items.eq( 0 ).children(); + + assert.hasClasses( element, "ui-menu ui-widget ui-widget-content" ); + assert.hasClasses( items[ 0 ], "ui-menu-item" ); + equal( items.eq( 0 ).children().length, 2, "Item has exactly 2 children when it has a sub menu" ); + assert.hasClasses( firstItemChildren[ 0 ], "ui-menu-item-wrapper" ); + assert.hasClasses( firstItemChildren[ 1 ], "ui-menu ui-widget ui-widget-content" ); + assert.hasClasses( firstItemChildren.eq( 1 ).children()[ 0 ], "ui-menu-item" ); + assert.hasClasses( firstItemChildren.eq( 1 ).children().eq( 0 ).children(), "ui-menu-item-wrapper" ); + assert.hasClasses( items[ 1 ], "ui-menu-item" ); + equal( items.eq( 1 ).children().length, 1, "Item has exactly 1 child when it does not have a sub menu" ); + assert.hasClasses( items[ 2 ], "ui-menu-item" ); + equal( items.eq( 2 ).children().length, 1, "Item has exactly 1 child when it does not have a sub menu" ); +}); + +test( "accessibility", function () { + expect( 4 ); + var element = $( "#menu1" ).menu(); + + equal( element.attr( "role" ), "menu", "main role" ); + 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" ); + + element.menu( "focus", $.Event(), element.children().eq( 0 ) ); + ok( /^ui-id-\d+$/.test( element.attr( "aria-activedescendant" ) ), "aria-activedescendant from generated id" ); + + // Item roles are tested in the role option tests +}); + +asyncTest( "#9044: Autofocus issue with dialog opened from menu widget", function() { + expect( 1 ); + var element = $( "#menu1" ).menu(); + + $( "<input>", { id: "test9044" } ).appendTo( "body" ); + + $( "#testID1" ).bind( "click", function() { + $( "#test9044" ).focus(); + }); + + testHelper.click( element, "3" ); + setTimeout( function() { + equal( document.activeElement.id, "test9044", "Focus was swallowed by menu" ); + $( "#test9044" ).remove(); + start(); + }); +}); + +asyncTest( "#9532: Need a way in Menu to keep ui-state-active class on selected item for Selectmenu", function( assert ) { + expect( 1 ); + var element = $( "#menu1" ).menu(), + firstChild = element.children().eq( 0 ), + wrapper = firstChild.children( ".ui-menu-item-wrapper" ); + + element.menu( "focus", null, firstChild ); + wrapper.addClass( "ui-state-active" ); + setTimeout( function() { + assert.hasClasses( wrapper, "ui-state-active" ); + start(); + }); +}); + +} ); |