diff options
Diffstat (limited to 'tests/unit/menu')
-rw-r--r-- | tests/unit/menu/menu.html | 6 | ||||
-rw-r--r-- | tests/unit/menu/menu_common.js | 3 | ||||
-rw-r--r-- | tests/unit/menu/menu_methods.js | 24 | ||||
-rw-r--r-- | tests/unit/menu/menu_options.js | 51 |
4 files changed, 74 insertions, 10 deletions
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index c58b9fc65..ed376232e 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -44,11 +44,7 @@ </head> <body> -<h1 id="qunit-header">jQuery UI Menu Test Suite</h1> -<h2 id="qunit-banner"></h2> -<div id="qunit-testrunner-toolbar"></div> -<h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"></ol> +<div id="qunit">jQuery UI Menu Test Suite</div> <div id="qunit-fixture"> <ul class="foo" id="menu1"> diff --git a/tests/unit/menu/menu_common.js b/tests/unit/menu/menu_common.js index 07295f1af..4a89a947a 100644 --- a/tests/unit/menu/menu_common.js +++ b/tests/unit/menu/menu_common.js @@ -1,6 +1,9 @@ TestHelpers.commonWidgetTests( "menu", { defaults: { disabled: false, + icons: { + submenu: "ui-icon-carat-1-e" + }, menus: "ul", position: { my: "left top", diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js index 0835f61ec..510ddb1d7 100644 --- a/tests/unit/menu/menu_methods.js +++ b/tests/unit/menu/menu_methods.js @@ -44,6 +44,30 @@ test( "refresh", function() { equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" ); }); +// TODO: test focus method + +// TODO: test blur method + +// TODO: test collapseAll method + +// TODO: test collapse method + +// TODO: test expand method + +// TODO: test next method + +// TODO: test prev method + +// TODO: test isFirstItem method + +// TODO: test isLastItem method + +// TODO: test nextPage method + +// TODO: test prevPage method + +// TODO: test select method + test( "destroy", function() { expect( 4 ); domEqual( "#menu1", function() { diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js index 27c2fabb3..a8b029201 100644 --- a/tests/unit/menu/menu_options.js +++ b/tests/unit/menu/menu_options.js @@ -18,7 +18,7 @@ test( "{ disabled: true }", function() { log(); } }); - ok( element.is( ".ui-state-disabled" ), "Missing ui-state-disabled class" ); + ok( element.hasClass( "ui-state-disabled" ), "Missing ui-state-disabled class" ); log( "click", true ); click( element, "1" ); log( "afterclick" ); @@ -33,14 +33,34 @@ test( "{ disabled: false }", function() { log(); } }); - ok( element.not( ".ui-state-disabled" ), "Has ui-state-disabled class" ); + ok( !element.hasClass( "ui-state-disabled" ), "Has ui-state-disabled class" ); log( "click", true ); click( element, "1" ); log( "afterclick" ); equal( logOutput(), "click,1,afterclick", "Click order not valid." ); }); -test( "{ role: 'menu' } ", function () { +test( "{ icons: default }", function() { + expect( 1 ); + var element = $( "#menu2" ).menu(); + equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-carat-1-e" ); +}); + +test( "{ icons: { submenu: 'custom' } }", function() { + expect( 1 ); + var element = $( "#menu2" ).menu({ + icons: { + submenu: "custom-class" + } + }); + equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon custom-class" ); +}); + +// TODO: test menus option + +// TODO: test position option + +test( "{ role: 'menu' } ", function() { var element = $( "#menu1" ).menu(), items = element.find( "li" ); expect( 2 + 5 * items.length ); @@ -55,16 +75,37 @@ test( "{ role: 'menu' } ", function () { }); }); -test( "{ role: 'listbox' } ", function () { +test( "{ role: 'listbox' } ", function() { var element = $( "#menu1" ).menu({ role: "listbox" }), items = element.find( "li" ); - expect( 2 + items.length ); + expect( 2 + 5 * items.length ); equal( element.attr( "role" ), "listbox" ); ok( items.length > 0, "number of menu items" ); items.each(function( item ) { + ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" ); + equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" ); equal( $( "a", this ).attr( "role" ), "option", "menu item ("+ item + ") role" ); + ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" ); + equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" ); + }); +}); + +test( "{ role: null }", function() { + var element = $( "#menu1" ).menu({ + role: null + }), + items = element.find( "li" ); + expect( 2 + 5 * items.length ); + strictEqual( element.attr( "role" ), undefined ); + ok( items.length > 0, "number of menu items" ); + items.each(function( item ) { + ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" ); + equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" ); + equal( $( "a", this ).attr( "role" ), undefined, "menu item ("+ item + ") role" ); + ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" ); + equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" ); }); }); |