aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-05-24 18:34:32 +0200
committerFelix Nagel <info@felixnagel.com>2012-05-24 18:34:32 +0200
commitb30184d885329317b9dbd70835d2c4d154f98475 (patch)
tree445acc2481e8456211c3e893e7789fe4b5978791 /tests/unit
parentec6d88fae464ffb432df6c8d2ed06ee9fa5b4dae (diff)
parenta1f604eb453208c80ec17c42c7bb4e3a1c624102 (diff)
downloadjquery-ui-b30184d885329317b9dbd70835d2c4d154f98475.tar.gz
jquery-ui-b30184d885329317b9dbd70835d2c4d154f98475.zip
Merge with master
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/autocomplete/autocomplete_common.js4
-rw-r--r--tests/unit/autocomplete/autocomplete_core.js37
-rw-r--r--tests/unit/button/button_core.js6
-rw-r--r--tests/unit/button/button_options.js4
-rw-r--r--tests/unit/button/button_tickets.js12
-rw-r--r--tests/unit/draggable/draggable_common.js2
-rw-r--r--tests/unit/draggable/draggable_events.js2
-rw-r--r--tests/unit/draggable/draggable_options.js8
-rw-r--r--tests/unit/index.html36
-rw-r--r--tests/unit/menu/menu.html2
-rw-r--r--tests/unit/menu/menu_common.js1
-rw-r--r--tests/unit/menu/menu_core.js13
-rw-r--r--tests/unit/menu/menu_events.js139
-rw-r--r--tests/unit/menu/menu_methods.js6
-rw-r--r--tests/unit/menu/menu_options.js26
-rw-r--r--tests/unit/resizable/resizable_common.js2
-rw-r--r--tests/unit/selectable/selectable_common.js2
-rw-r--r--tests/unit/slider/slider_common.js2
-rw-r--r--tests/unit/sortable/sortable_common.js2
-rw-r--r--tests/unit/sortable/sortable_options.js2
-rw-r--r--tests/unit/tabs/tabs.html2
-rw-r--r--tests/unit/tabs/tabs_common.js3
-rw-r--r--tests/unit/tabs/tabs_common_deprecated.js2
-rw-r--r--tests/unit/tabs/tabs_core.js13
-rw-r--r--tests/unit/tabs/tabs_deprecated.html2
-rw-r--r--tests/unit/tabs/tabs_deprecated.js61
-rw-r--r--tests/unit/tabs/tabs_events.js28
-rw-r--r--tests/unit/tabs/tabs_methods.js22
-rw-r--r--tests/unit/tabs/tabs_options.js18
-rw-r--r--tests/unit/tabs/tabs_test_helpers.js2
-rw-r--r--tests/unit/tooltip/tooltip.html1
-rw-r--r--tests/unit/tooltip/tooltip_core.js25
-rw-r--r--tests/unit/tooltip/tooltip_events.js2
-rw-r--r--tests/unit/tooltip/tooltip_methods.js6
-rw-r--r--tests/unit/tooltip/tooltip_options.js16
35 files changed, 322 insertions, 189 deletions
diff --git a/tests/unit/autocomplete/autocomplete_common.js b/tests/unit/autocomplete/autocomplete_common.js
index c090ce4df..e1d24ef8d 100644
--- a/tests/unit/autocomplete/autocomplete_common.js
+++ b/tests/unit/autocomplete/autocomplete_common.js
@@ -4,6 +4,10 @@ TestHelpers.commonWidgetTests( "autocomplete", {
autoFocus: false,
delay: 300,
disabled: false,
+ messages: {
+ noResults: "No search results.",
+ results: $.ui.autocomplete.prototype.options.messages.results
+ },
minLength: 1,
position: {
my: "left top",
diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js
index daeea0972..f0ad36a57 100644
--- a/tests/unit/autocomplete/autocomplete_core.js
+++ b/tests/unit/autocomplete/autocomplete_core.js
@@ -152,4 +152,41 @@ asyncTest( "handle race condition", function() {
}
});
+test( "ARIA", function() {
+ expect( 7 );
+ var element = $( "#autocomplete" ).autocomplete({
+ source: [ "java", "javascript" ]
+ }),
+ liveRegion = element.data( "ui-autocomplete" ).liveRegion;
+
+ equal( liveRegion.text(), "", "Empty live region on create" );
+
+ element.autocomplete( "search", "j" );
+ equal( liveRegion.text(), "2 results are available, use up and down arrow keys to navigate.",
+ "Live region for multiple values" );
+
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equal( liveRegion.text(), "2 results are available, use up and down arrow keys to navigate.",
+ "Live region not changed on focus" );
+
+ element.one( "autocompletefocus", function( event ) {
+ event.preventDefault();
+ });
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equal( liveRegion.text(), "javascript",
+ "Live region updated when default focus is prevented" );
+
+ element.autocomplete( "search", "javas" );
+ equal( liveRegion.text(), "1 result is available, use up and down arrow keys to navigate.",
+ "Live region for one value" );
+
+ element.autocomplete( "search", "z" );
+ equal( liveRegion.text(), "No search results.",
+ "Live region for no values" );
+
+ element.autocomplete( "search", "j" );
+ equal( liveRegion.text(), "2 results are available, use up and down arrow keys to navigate.",
+ "Live region for multiple values" );
+});
+
}( jQuery ) );
diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js
index 0d93ecedf..c274a8473 100644
--- a/tests/unit/button/button_core.js
+++ b/tests/unit/button/button_core.js
@@ -34,7 +34,7 @@ function assert(noForm, form1, form2) {
}
test("radio groups", function() {
- $(":radio").button();
+ $("input[type=radio]").button();
assert(":eq(0)", ":eq(1)", ":eq(2)");
// click outside of forms
@@ -61,7 +61,7 @@ test("buttonset", function() {
var set = $("#radio1").buttonset();
ok( set.is(".ui-buttonset") );
deepEqual( set.children(".ui-button").length, 3 );
- deepEqual( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
+ deepEqual( set.children("input[type=radio].ui-helper-hidden-accessible").length, 3 );
ok( set.children("label:eq(0)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
@@ -76,7 +76,7 @@ test("buttonset (rtl)", function() {
set = $("#radio1").buttonset();
ok( set.is(".ui-buttonset") );
deepEqual( set.children(".ui-button").length, 3 );
- deepEqual( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
+ deepEqual( set.children("input[type=radio].ui-helper-hidden-accessible").length, 3 );
ok( set.children("label:eq(0)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js
index 9ef4a19db..3dd361ac9 100644
--- a/tests/unit/button/button_options.js
+++ b/tests/unit/button/button_options.js
@@ -53,6 +53,7 @@ test("text false with icon", function() {
test("label, default", function() {
$("#button").button();
deepEqual( $("#button").text(), "Label" );
+ deepEqual( $( "#button").button( "option", "label" ), "Label" );
$("#button").button("destroy");
});
@@ -62,12 +63,14 @@ test("label", function() {
label: "xxx"
});
deepEqual( $("#button").text(), "xxx" );
+ deepEqual( $("#button").button( "option", "label" ), "xxx" );
$("#button").button("destroy");
});
test("label default with input type submit", function() {
deepEqual( $("#submit").button().val(), "Label" );
+ deepEqual( $("#submit").button( "option", "label" ), "Label" );
});
test("label with input type submit", function() {
@@ -75,6 +78,7 @@ test("label with input type submit", function() {
label: "xxx"
}).val();
deepEqual( label, "xxx" );
+ deepEqual( $("#submit").button( "option", "label" ), "xxx" );
});
test("icons", function() {
diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js
index 624d16716..fe0d82fd6 100644
--- a/tests/unit/button/button_tickets.js
+++ b/tests/unit/button/button_tickets.js
@@ -7,7 +7,7 @@ module( "button: tickets" );
test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
$( "#radio01" ).next().andSelf().hide();
- var set = $( "#radio0" ).buttonset({ items: ":radio:visible" });
+ var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) );
});
@@ -30,23 +30,23 @@ test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard
test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
- group.find( "input:checkbox" ).button();
+ group.find( "input[type=checkbox]" ).button();
ok( group.find( "label" ).is( ".ui-button" ) );
group = $( "<input type='checkbox' id='t7092b'><label for='t7092b'></label>" );
- group.filter( "input:checkbox" ).button();
+ group.filter( "input[type=checkbox]" ).button();
ok( group.filter( "label" ).is( ".ui-button" ) );
group = $( "<span><input type='checkbox' id='t7092c'></span><label for='t7092c'></label>" );
- group.find( "input:checkbox" ).button();
+ group.find( "input[type=checkbox]" ).button();
ok( group.filter( "label" ).is( ".ui-button" ) );
group = $( "<span><input type='checkbox' id='t7092d'></span><span><label for='t7092d'></label></span>" );
- group.find( "input:checkbox" ).button();
+ group.find( "input[type=checkbox]" ).button();
ok( group.find( "label" ).is( ".ui-button" ) );
group = $( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" );
- group.filter( "input:checkbox" ).button();
+ group.filter( "input[type=checkbox]" ).button();
ok( group.find( "label" ).is( ".ui-button" ) );
});
diff --git a/tests/unit/draggable/draggable_common.js b/tests/unit/draggable/draggable_common.js
index b47b139cd..64f8ce4a3 100644
--- a/tests/unit/draggable/draggable_common.js
+++ b/tests/unit/draggable/draggable_common.js
@@ -3,7 +3,7 @@ TestHelpers.commonWidgetTests( "draggable", {
addClasses: true,
appendTo: "parent",
axis: false,
- cancel: ":input,option",
+ cancel: "input,textarea,button,select,option",
connectToSortable: false,
containment: false,
cursor: "auto",
diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/draggable_events.js
index 85ba824d8..2b2104ed4 100644
--- a/tests/unit/draggable/draggable_events.js
+++ b/tests/unit/draggable/draggable_events.js
@@ -5,7 +5,7 @@
module("draggable: events");
-test("callbacks occurance count", function() {
+test("callbacks occurrence count", function() {
expect(3);
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index 464e025dd..ea4611d69 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -106,15 +106,15 @@ test("{ axis: ? }, unexpected", function() {
});
});
-test("{ cancel: ':input,option' }, default", function() {
+test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
$('<div id="draggable-option-cancel-default"><input type="text"></div>').appendTo('#main');
- el = $("#draggable-option-cancel-default").draggable({ cancel: ":input,option" });
+ el = $("#draggable-option-cancel-default").draggable({ cancel: "input,textarea,button,select,option" });
drag("#draggable-option-cancel-default", 50, 50);
moved(50, 50);
- el = $("#draggable-option-cancel-default").draggable({ cancel: ":input,option" });
- drag("#draggable-option-cancel-default :input", 50, 50);
+ el = $("#draggable-option-cancel-default").draggable({ cancel: "input,textarea,button,select,option" });
+ drag("#draggable-option-cancel-default input", 50, 50);
moved(0, 0);
el.draggable("destroy");
diff --git a/tests/unit/index.html b/tests/unit/index.html
index b73ede29c..33a326370 100644
--- a/tests/unit/index.html
+++ b/tests/unit/index.html
@@ -6,39 +6,9 @@
<link rel="stylesheet" href="../../themes/base/jquery.ui.core.css">
<link rel="stylesheet" href="../../themes/base/jquery.ui.theme.css">
- <style>
- body {
- font-size: 62.5%;
- }
- .ui-widget-header {
- padding: 0.2em 0.5em;
- margin: 0;
- }
- .ui-widget-content {
- padding: 1em;
- margin-bottom: 1em;
- }
- ul {
- margin: 0;
- list-style: none;
- }
- li {
- line-height: 2em;
- }
- </style>
-
- <script src="../jquery.js"></script>
- <script>
- $(function() {
- $( "#main" )
- .addClass( "ui-widget" )
- .find( "h1, h2" )
- .addClass( "ui-widget-header ui-corner-top" )
- .next()
- .addClass( "ui-widget-content ui-corner-bottom" );
-
- });
- </script>
+ <link rel="stylesheet" href="../index.css">
+ <script src="../jquery-1.7.2.js"></script>
+ <script src="../index.js"></script>
</head>
<body>
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html
index fca45697f..62585d863 100644
--- a/tests/unit/menu/menu.html
+++ b/tests/unit/menu/menu.html
@@ -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>
diff --git a/tests/unit/menu/menu_common.js b/tests/unit/menu/menu_common.js
index ddcdbebf2..07295f1af 100644
--- a/tests/unit/menu/menu_common.js
+++ b/tests/unit/menu/menu_common.js
@@ -6,6 +6,7 @@ TestHelpers.commonWidgetTests( "menu", {
my: "left top",
at: "right top"
},
+ role: "menu",
// callbacks
blur: null,
diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js
index f2de7ef1a..68b625687 100644
--- a/tests/unit/menu/menu_core.js
+++ b/tests/unit/menu/menu_core.js
@@ -26,17 +26,4 @@ test("accessibility", function () {
equal( menu.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
});
-test("items class and role", function () {
- var menu = $('#menu1').menu();
- expect(1 + 5 * $("li",menu).length);
- ok( ($("li",menu).length > 0 ), "number of menu items");
- $("li",menu).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"), "menuitem", "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 + ") ");
- });
-});
-
})(jQuery);
diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js
index 4cb083240..ec3e7d3c4 100644
--- a/tests/unit/menu/menu_events.js
+++ b/tests/unit/menu/menu_events.js
@@ -41,49 +41,62 @@ 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'" );
-
- },
- blur: function( event, ui ) {
- equal( event.originalEvent.type, "click", "blur triggered 'click'" );
- equal( event.type, "menublur", "blur event.type is 'menublur'" );
- }
- });
-
- $menu.find( "li a:first" ).trigger( "click" );
- $( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" );
+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'" );
+ }
+ }
+ });
+
+ click( $menu, "1" );
+ setTimeout( function() {
+ $menu.blur();
+ start();
+ }, 350);
+});
- $("#remove").remove();
+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 blur on custom item menu: click", function() {
- expect( 4 );
- var $menu = $( "#menu5" ).menu({
+test( "handle focus of menu with active item", function() {
+ expect( 1 );
+ var element = $( "#menu1" ).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"
+ log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
+ }
});
- click($('#menu5'),"1");
- $( "<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");
});
-*/
asyncTest( "handle submenu auto collapse: mouseleave", function() {
expect( 4 );
@@ -208,7 +221,7 @@ test("handle keyboard navigation on menu without scroll and without submenus", f
});
asyncTest("handle keyboard navigation on menu without scroll and with submenus", function() {
- expect(14);
+ expect(16);
var element = $('#menu2').menu({
select: function(event, ui) {
log($(ui.item[0]).text());
@@ -290,11 +303,23 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus",
equal( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)");
log("keydown",true);
- element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.SPACE } );
setTimeout( menukeyboard4, 50 );
}
function menukeyboard4() {
+ equal( $("#log").html(), "0,keydown,", "Keydown SPACE (open submenu)");
+
+ log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
+ equal( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)");
+
+ log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ setTimeout( menukeyboard5, 50 );
+ }
+
+ function menukeyboard5() {
equal( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
log("keydown",true);
@@ -524,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();
+ }, 500);
+});
+
})(jQuery);
diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js
index 6ad7bc134..fc4fce4f1 100644
--- a/tests/unit/menu/menu_methods.js
+++ b/tests/unit/menu/menu_methods.js
@@ -42,6 +42,12 @@ test("destroy", function() {
domEqual("#menu1", function() {
$("#menu1").menu().menu("destroy");
});
+ domEqual("#menu5", function() {
+ $("#menu5").menu().menu("destroy");
+ });
+ domEqual("#menu6", function() {
+ $("#menu6").menu().menu("destroy");
+ });
});
diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js
index e651fd2d1..306f575ea 100644
--- a/tests/unit/menu/menu_options.js
+++ b/tests/unit/menu/menu_options.js
@@ -38,4 +38,30 @@ test( "{ disabled: false }", function() {
equal( $("#log").html(), "afterclick,1,click,", "Click order not valid.");
});
+test("{ role: 'menu' } ", function () {
+ var menu = $('#menu1').menu();
+ expect(2 + 5 * $("li", menu).length);
+ equal( menu.attr( "role" ), "menu" );
+ ok( $("li", menu).length > 0, "number of menu items");
+ $("li", menu).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"), "menuitem", "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: 'listbox' } ", function () {
+ var menu = $('#menu1').menu({
+ role: "listbox"
+ });
+ expect(2 + $("li", menu).length);
+ equal( menu.attr( "role" ), "listbox" );
+ ok( ($("li", menu).length > 0 ), "number of menu items");
+ $("li", menu).each(function(item) {
+ equal( $("a", this).attr("role"), "option", "menu item ("+ item + ") role");
+ });
+});
+
})(jQuery);
diff --git a/tests/unit/resizable/resizable_common.js b/tests/unit/resizable/resizable_common.js
index 617cdd2ad..119f5bd0e 100644
--- a/tests/unit/resizable/resizable_common.js
+++ b/tests/unit/resizable/resizable_common.js
@@ -6,7 +6,7 @@ TestHelpers.commonWidgetTests('resizable', {
animateEasing: 'swing',
aspectRatio: false,
autoHide: false,
- cancel: ':input,option',
+ cancel: 'input,textarea,button,select,option',
containment: false,
delay: 0,
disabled: false,
diff --git a/tests/unit/selectable/selectable_common.js b/tests/unit/selectable/selectable_common.js
index 27714d0ae..885e79401 100644
--- a/tests/unit/selectable/selectable_common.js
+++ b/tests/unit/selectable/selectable_common.js
@@ -2,7 +2,7 @@ TestHelpers.commonWidgetTests('selectable', {
defaults: {
appendTo: 'body',
autoRefresh: true,
- cancel: ':input,option',
+ cancel: 'input,textarea,button,select,option',
delay: 0,
disabled: false,
distance: 0,
diff --git a/tests/unit/slider/slider_common.js b/tests/unit/slider/slider_common.js
index 8a0b347f3..ccf793549 100644
--- a/tests/unit/slider/slider_common.js
+++ b/tests/unit/slider/slider_common.js
@@ -1,7 +1,7 @@
TestHelpers.commonWidgetTests( "slider", {
defaults: {
animate: false,
- cancel: ':input,option',
+ cancel: 'input,textarea,button,select,option',
delay: 0,
disabled: false,
distance: 0,
diff --git a/tests/unit/sortable/sortable_common.js b/tests/unit/sortable/sortable_common.js
index b5fc05a5d..ae21f7dd2 100644
--- a/tests/unit/sortable/sortable_common.js
+++ b/tests/unit/sortable/sortable_common.js
@@ -2,7 +2,7 @@ TestHelpers.commonWidgetTests( "sortable", {
defaults: {
appendTo: "parent",
axis: false,
- cancel: ":input,option",
+ cancel: "input,textarea,button,select,option",
connectWith: false,
containment: false,
cursor: "auto",
diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js
index 507d5dcfa..a043e68fe 100644
--- a/tests/unit/sortable/sortable_options.js
+++ b/tests/unit/sortable/sortable_options.js
@@ -29,7 +29,7 @@ test("{ axis: ? }, unexpected", function() {
ok(false, "missing test - untested code is broken code.");
});
-test("{ cancel: ':input,button' }, default", function() {
+test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
ok(false, "missing test - untested code is broken code.");
});
diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html
index b961c60f3..b9fa507d8 100644
--- a/tests/unit/tabs/tabs.html
+++ b/tests/unit/tabs/tabs.html
@@ -57,7 +57,7 @@
<li><a href="#colon:test"><span>1</span></a></li>
<li><a href="#inline-style"><span>2</span></a></li>
<li><a href="data/test.html#test"><span>3</span></a></li>
- <li><a href="data/test.html" aria-controls="custom-id"><span>4</span></a></li>
+ <li aria-controls="custom-id"><a href="data/test.html"><span>4</span></a></li>
<li><a href="data/test.html" title="∫ßáö Սե"><span>5</span></a></li>
</ul>
<div id="colon:test"></div>
diff --git a/tests/unit/tabs/tabs_common.js b/tests/unit/tabs/tabs_common.js
index 7ffb05da4..b98ff3575 100644
--- a/tests/unit/tabs/tabs_common.js
+++ b/tests/unit/tabs/tabs_common.js
@@ -4,7 +4,8 @@ TestHelpers.commonWidgetTests( "tabs", {
collapsible: false,
disabled: false,
event: "click",
- fx: null,
+ hide: null,
+ show: null,
// callbacks
activate: null,
diff --git a/tests/unit/tabs/tabs_common_deprecated.js b/tests/unit/tabs/tabs_common_deprecated.js
index fdcff21b3..718ae8272 100644
--- a/tests/unit/tabs/tabs_common_deprecated.js
+++ b/tests/unit/tabs/tabs_common_deprecated.js
@@ -7,9 +7,11 @@ TestHelpers.commonWidgetTests( "tabs", {
cookie: null,
disabled: false,
event: "click",
+ hide: null,
fx: null,
idPrefix: "ui-tabs-",
panelTemplate: "<div></div>",
+ // show: null, // conflicts with old show callback
spinner: "<em>Loading&#8230;</em>",
tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>",
diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js
index b9bd81987..fb3c306e6 100644
--- a/tests/unit/tabs/tabs_core.js
+++ b/tests/unit/tabs/tabs_core.js
@@ -47,14 +47,15 @@ test( "disconnected from DOM", function() {
test( "aria-controls", function() {
expect( 7 );
var element = $( "#tabs1" ).tabs(),
- tabs = element.find( ".ui-tabs-nav a" );
+ tabs = element.find( ".ui-tabs-nav li" );
tabs.each(function() {
- var tab = $( this );
- equal( tab.prop( "hash" ).substring( 1 ), tab.attr( "aria-controls" ) );
+ var tab = $( this ),
+ anchor = tab.find( ".ui-tabs-anchor" );
+ equal( anchor.prop( "hash" ).substring( 1 ), tab.attr( "aria-controls" ) );
});
element = $( "#tabs2" ).tabs();
- tabs = element.find( ".ui-tabs-nav a" );
+ tabs = element.find( ".ui-tabs-nav li" );
equal( tabs.eq( 0 ).attr( "aria-controls" ), "colon:test" );
equal( tabs.eq( 1 ).attr( "aria-controls" ), "inline-style" );
ok( /^ui-tabs-\d+$/.test( tabs.eq( 2 ).attr( "aria-controls" ) ), "generated id" );
@@ -86,11 +87,11 @@ test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", funct
element.tabs({
beforeLoad: function( event, ui ) {
event.preventDefault();
- ok( false, 'should not be an ajax tab');
+ ok( false, "should not be an ajax tab" );
}
});
- equal( element.find( ".ui-tabs-nav a" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" );
+ equal( element.find( ".ui-tabs-nav li" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" );
state( element, 1 );
});
diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html
index 09afc91b4..e58382efb 100644
--- a/tests/unit/tabs/tabs_deprecated.html
+++ b/tests/unit/tabs/tabs_deprecated.html
@@ -56,7 +56,7 @@
<li><a href="#colon:test"><span>1</span></a></li>
<li><a href="#inline-style"><span>2</span></a></li>
<li><a href="data/test.html#test"><span>3</span></a></li>
- <li><a href="data/test.html" aria-controls="custom-id"><span>4</span></a></li>
+ <li aria-controls="custom-id"><a href="data/test.html"><span>4</span></a></li>
<li><a href="data/test.html" title="∫ßáö Սե"><span>5</span></a></li>
</ul>
<div id="colon:test"></div>
diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js
index 66768b866..351433348 100644
--- a/tests/unit/tabs/tabs_deprecated.js
+++ b/tests/unit/tabs/tabs_deprecated.js
@@ -107,11 +107,11 @@ test( "tabTemplate + panelTemplate", function() {
});
element.tabs( "add", "#new", "New" );
tab = element.find( ".ui-tabs-nav li" ).last();
- anchor = tab.find( "a" );
+ anchor = tab.find( ".ui-tabs-anchor" );
equal( tab.text(), "New", "label" );
ok( tab.hasClass( "customTab" ), "tab custom class" );
equal( anchor.attr( "href" ), "http://example.com/#new", "href" );
- equal( anchor.attr( "aria-controls" ), "new", "aria-controls" );
+ equal( tab.attr( "aria-controls" ), "new", "aria-controls" );
ok( element.find( "#new" ).hasClass( "customPanel" ), "panel custom class" );
});
@@ -210,7 +210,7 @@ test( "selected", function() {
equal( element.tabs( "option", "selected" ), 0 );
state( element, 1, 0, 0 );
- element.find( ".ui-tabs-nav a" ).eq( 1 ).click();
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).click();
equal( element.tabs( "option", "selected" ), 1 );
state( element, 0, 1, 0 );
@@ -226,17 +226,18 @@ module( "tabs (deprecated): events" );
asyncTest( "load", function() {
expect( 15 );
- var tab, panelId, panel,
+ var tab, anchor, panelId, panel,
element = $( "#tabs2" );
// init
element.one( "tabsload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
+ tab = element.find( ".ui-tabs-nav li" ).eq( 2 );
+ anchor = tab.find( ".ui-tabs-anchor" );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- strictEqual( ui.tab, tab[ 0 ], "tab" );
+ strictEqual( ui.tab, anchor[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 1, 0, 0 );
@@ -247,12 +248,13 @@ asyncTest( "load", function() {
function tabsload1() {
// .option()
element.one( "tabsload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 3 );
+ tab = element.find( ".ui-tabs-nav li" ).eq( 3 );
+ anchor = tab.find( ".ui-tabs-anchor" );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- strictEqual( ui.tab, tab[ 0 ], "tab" );
+ strictEqual( ui.tab, anchor[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 0, 1, 0 );
@@ -264,18 +266,19 @@ asyncTest( "load", function() {
function tabsload2() {
// click, change panel content
element.one( "tabsload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 4 );
+ tab = element.find( ".ui-tabs-nav li" ).eq( 4 );
+ anchor = tab.find( ".ui-tabs-anchor" );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
equal( event.originalEvent.type, "click", "originalEvent" );
- strictEqual( ui.tab, tab[ 0 ], "tab" );
+ strictEqual( ui.tab, anchor[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
state( element, 0, 0, 0, 0, 1 );
start();
});
- element.find( ".ui-tabs-nav a" ).eq( 4 ).click();
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 4 ).click();
}
});
@@ -285,7 +288,7 @@ test( "enable", function() {
var element = $( "#tabs1" ).tabs({
disabled: [ 0, 1 ],
enable: function( event, ui ) {
- equal( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
+ equal( ui.tab, element.find( ".ui-tabs-nav .ui-tabs-anchor" )[ 1 ], "ui.tab" );
equal( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
}
@@ -300,7 +303,7 @@ test( "disable", function() {
var element = $( "#tabs1" ).tabs({
disable: function( event, ui ) {
- equal( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
+ equal( ui.tab, element.find( ".ui-tabs-nav .ui-tabs-anchor" )[ 1 ], "ui.tab" );
equal( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
}
@@ -318,13 +321,13 @@ test( "show", function() {
active: false,
collapsible: true
}),
- tabs = element.find( ".ui-tabs-nav a" ),
+ anchors = element.find( ".ui-tabs-nav .ui-tabs-anchor" ),
panels = element.find( ".ui-tabs-panel" );
// from collapsed
element.one( "tabsshow", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- strictEqual( ui.tab, tabs[ 0 ], "ui.tab" );
+ strictEqual( ui.tab, anchors[ 0 ], "ui.tab" );
strictEqual( ui.panel, panels[ 0 ], "ui.panel" );
equal( ui.index, 0, "ui.index" );
state( element, 1, 0, 0 );
@@ -335,12 +338,12 @@ test( "show", function() {
// switching tabs
element.one( "tabsshow", function( event, ui ) {
equal( event.originalEvent.type, "click", "originalEvent" );
- strictEqual( ui.tab, tabs[ 1 ], "ui.tab" );
+ strictEqual( ui.tab, anchors[ 1 ], "ui.tab" );
strictEqual( ui.panel, panels[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
state( element, 0, 1, 0 );
});
- tabs.eq( 1 ).click();
+ anchors.eq( 1 ).click();
state( element, 0, 1, 0 );
// collapsing
@@ -358,13 +361,13 @@ test( "select", function() {
active: false,
collapsible: true
}),
- tabs = element.find( ".ui-tabs-nav a" ),
+ anchors = element.find( ".ui-tabs-nav .ui-tabs-anchor" ),
panels = element.find( ".ui-tabs-panel" );
// from collapsed
element.one( "tabsselect", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- strictEqual( ui.tab, tabs[ 0 ], "ui.tab" );
+ strictEqual( ui.tab, anchors[ 0 ], "ui.tab" );
strictEqual( ui.panel, panels[ 0 ], "ui.panel" );
equal( ui.index, 0, "ui.index" );
state( element, 0, 0, 0 );
@@ -375,12 +378,12 @@ test( "select", function() {
// switching tabs
element.one( "tabsselect", function( event, ui ) {
equal( event.originalEvent.type, "click", "originalEvent" );
- strictEqual( ui.tab, tabs[ 1 ], "ui.tab" );
+ strictEqual( ui.tab, anchors[ 1 ], "ui.tab" );
strictEqual( ui.panel, panels[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
state( element, 1, 0, 0 );
});
- tabs.eq( 1 ).click();
+ anchors.eq( 1 ).click();
state( element, 0, 1, 0 );
// collapsing
@@ -414,11 +417,11 @@ test( "add", function() {
element.tabs( "add", "#new", "New" );
state( element, 1, 0, 0, 0 );
tab = element.find( ".ui-tabs-nav li" ).last();
- anchor = tab.find( "a" );
+ anchor = tab.find( ".ui-tabs-anchor" );
equal( tab.text(), "New", "label" );
equal( stripLeadingSlash( anchor[0].pathname ), stripLeadingSlash( location.pathname ), "href pathname" );
equal( anchor[0].hash, "#new", "href hash" );
- equal( anchor.attr( "aria-controls" ), "new", "aria-controls" );
+ equal( tab.attr( "aria-controls" ), "new", "aria-controls" );
ok( !tab.hasClass( "ui-state-hover" ), "not hovered" );
anchor.simulate( "mouseover" );
ok( tab.hasClass( "ui-state-hover" ), "hovered" );
@@ -429,17 +432,17 @@ test( "add", function() {
element.one( "tabsadd", function( event, ui ) {
equal( ui.index, 1, "ui.index" );
equal( $( ui.tab ).text(), "New Remote", "ui.tab" );
- equal( ui.panel.id, $( ui.tab ).attr( "aria-controls" ), "ui.panel" );
+ equal( ui.panel.id, $( ui.tab ).closest( "li" ).attr( "aria-controls" ), "ui.panel" );
});
element.tabs( "add", "data/test.html", "New Remote", 1 );
state( element, 0, 0, 0, 0, 1 );
tab = element.find( ".ui-tabs-nav li" ).eq( 1 );
- anchor = tab.find( "a" );
+ anchor = tab.find( ".ui-tabs-anchor" );
equal( tab.text(), "New Remote", "label" );
equal( stripLeadingSlash( stripLeadingSlash(
anchor[0].pathname.replace( stripLeadingSlash( location.pathname ).split( "/" ).slice( 0, -1 ).join( "/" ), "" )
) ), "data/test.html", "href" );
- ok( /^ui-tabs-\d+$/.test( anchor.attr( "aria-controls" ) ), "aria controls" );
+ ok( /^ui-tabs-\d+$/.test( tab.attr( "aria-controls" ) ), "aria controls" );
ok( !tab.hasClass( "ui-state-hover" ), "not hovered" );
anchor.simulate( "mouseover" );
ok( tab.hasClass( "ui-state-hover" ), "hovered" );
@@ -560,10 +563,10 @@ test( "url", function() {
expect( 2 );
var element = $( "#tabs2" ).tabs(),
- tab = element.find( "a" ).eq( 3 );
+ anchor = element.find( ".ui-tabs-anchor" ).eq( 3 );
element.tabs( "url", 3, "data/test2.html" );
- equal( tab.attr( "href" ), "data/test2.html", "href was updated" );
+ equal( anchor.attr( "href" ), "data/test2.html", "href was updated" );
element.one( "tabsbeforeload", function( event, ui ) {
equal( ui.ajaxSettings.url, "data/test2.html", "ajaxSettings.url" );
event.preventDefault();
@@ -582,7 +585,7 @@ asyncTest( "abort", function() {
});
});
// prevent IE from caching the request, so that it won't resolve before we call abort
- element.find( ".ui-tabs-nav li:eq(2) a" ).attr( "href", function( href ) {
+ element.find( ".ui-tabs-nav li:eq(2) .ui-tabs-anchor" ).attr( "href", function( href ) {
return href + "?" + (+ new Date());
});
element.tabs( "option", "active", 2 );
diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js
index f33686581..57011bdad 100644
--- a/tests/unit/tabs/tabs_events.js
+++ b/tests/unit/tabs/tabs_events.js
@@ -8,7 +8,7 @@ test( "create", function() {
expect( 10 );
var element = $( "#tabs1" ),
- tabs = element.find( "ul a" ),
+ tabs = element.find( "ul li" ),
panels = element.children( "div" );
element.tabs({
@@ -50,7 +50,8 @@ test( "beforeActivate", function() {
active: false,
collapsible: true
}),
- tabs = element.find( ".ui-tabs-nav a" ),
+ tabs = element.find( ".ui-tabs-nav li" ),
+ anchors = tabs.find( ".ui-tabs-anchor" ),
panels = element.find( ".ui-tabs-panel" );
// from collapsed
@@ -80,7 +81,7 @@ test( "beforeActivate", function() {
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
state( element, 1, 0, 0 );
});
- tabs.eq( 1 ).click();
+ anchors.eq( 1 ).click();
state( element, 0, 1, 0 );
// collapsing
@@ -120,7 +121,8 @@ test( "activate", function() {
active: false,
collapsible: true
}),
- tabs = element.find( ".ui-tabs-nav a" ),
+ tabs = element.find( ".ui-tabs-nav li" ),
+ anchors = element.find( ".ui-tabs-anchor" ),
panels = element.find( ".ui-tabs-panel" );
// from collapsed
@@ -150,7 +152,7 @@ test( "activate", function() {
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
state( element, 0, 1, 0 );
});
- tabs.eq( 1 ).click();
+ anchors.eq( 1 ).click();
state( element, 0, 1, 0 );
// collapsing
@@ -186,7 +188,7 @@ test( "beforeLoad", function() {
// init
element.one( "tabsbeforeload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
+ tab = element.find( ".ui-tabs-nav li" ).eq( 2 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
@@ -208,7 +210,7 @@ test( "beforeLoad", function() {
// .option()
element.one( "tabsbeforeload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
+ tab = element.find( ".ui-tabs-nav li" ).eq( 2 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
@@ -230,7 +232,7 @@ test( "beforeLoad", function() {
// click, change panel content
element.one( "tabsbeforeload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 3 );
+ tab = element.find( ".ui-tabs-nav li" ).eq( 3 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
@@ -245,7 +247,7 @@ test( "beforeLoad", function() {
event.preventDefault();
state( element, 0, 0, 1, 0, 0 );
});
- element.find( ".ui-tabs-nav a" ).eq( 3 ).click();
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 3 ).click();
state( element, 0, 0, 0, 1, 0 );
// .toLowerCase() is needed to convert <P> to <p> in old IEs
equal( panel.html().toLowerCase(), "<p>testing</p>", "panel html after" );
@@ -260,7 +262,7 @@ if ( $.uiBackCompat === false ) {
// init
element.one( "tabsload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
+ tab = element.find( ".ui-tabs-nav li" ).eq( 2 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
@@ -278,7 +280,7 @@ if ( $.uiBackCompat === false ) {
function tabsload1() {
// .option()
element.one( "tabsload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 3 );
+ tab = element.find( ".ui-tabs-nav li" ).eq( 3 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
@@ -297,7 +299,7 @@ if ( $.uiBackCompat === false ) {
function tabsload2() {
// click, change panel content
element.one( "tabsload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 4 );
+ tab = element.find( ".ui-tabs-nav li" ).eq( 4 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
@@ -310,7 +312,7 @@ if ( $.uiBackCompat === false ) {
state( element, 0, 0, 0, 0, 1 );
start();
});
- element.find( ".ui-tabs-nav a" ).eq( 4 ).click();
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 4 ).click();
}
});
}
diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js
index 0837995e6..ed3e73745 100644
--- a/tests/unit/tabs/tabs_methods.js
+++ b/tests/unit/tabs/tabs_methods.js
@@ -97,7 +97,7 @@ test( "refresh", function() {
element.tabs( "refresh" );
state( element, 1, 0, 0, 0 );
disabled( element, [ 1 ] );
- equal( element.find( "#" + $( "#newTab a" ).attr( "aria-controls" ) ).length, 1,
+ equal( element.find( "#" + $( "#newTab" ).attr( "aria-controls" ) ).length, 1,
"panel added for remote tab" );
// remove all tabs
@@ -156,7 +156,7 @@ asyncTest( "load", function() {
// load content of inactive tab
// useful for preloading content with custom caching
element.one( "tabsbeforeload", function( event, ui ) {
- var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ var tab = element.find( ".ui-tabs-nav li" ).eq( 3 ),
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
@@ -171,13 +171,17 @@ asyncTest( "load", function() {
// TODO: remove wrapping in 2.0
var uiTab = $( ui.tab ),
uiPanel = $( ui.panel ),
- tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ tab = element.find( ".ui-tabs-nav li" ).eq( 3 ),
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
equal( uiTab.length, 1, "tab length" );
- strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
+ if ( $.uiBackCompat === false ) {
+ strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
+ } else {
+ strictEqual( uiTab[ 0 ], tab.find( ".ui-tabs-anchor" )[ 0 ], "tab" );
+ }
equal( uiPanel.length, 1, "panel length" );
strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
equal( uiPanel.find( "p" ).length, 1, "panel html" );
@@ -203,7 +207,7 @@ asyncTest( "load", function() {
function tabsload2() {
// reload content of active tab
element.one( "tabsbeforeload", function( event, ui ) {
- var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ var tab = element.find( ".ui-tabs-nav li" ).eq( 3 ),
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
@@ -218,13 +222,17 @@ asyncTest( "load", function() {
// TODO: remove wrapping in 2.0
var uiTab = $( ui.tab ),
uiPanel = $( ui.panel ),
- tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ tab = element.find( ".ui-tabs-nav li" ).eq( 3 ),
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
equal( uiTab.length, 1, "tab length" );
- strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
+ if ( $.uiBackCompat === false ) {
+ strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
+ } else {
+ strictEqual( uiTab[ 0 ], tab.find( ".ui-tabs-anchor" )[ 0 ], "tab" );
+ }
equal( uiPanel.length, 1, "panel length" );
strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
state( element, 0, 0, 0, 1, 0 );
diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js
index ae9e7bdc6..df6827c57 100644
--- a/tests/unit/tabs/tabs_options.js
+++ b/tests/unit/tabs/tabs_options.js
@@ -57,7 +57,7 @@ test( "{ active: Number }", function() {
equal( element.tabs( "option", "active" ), 0 );
state( element, 1, 0, 0 );
- element.find( ".ui-tabs-nav a" ).eq( 1 ).click();
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).click();
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
@@ -110,7 +110,7 @@ test( "{ collapsible: false }", function() {
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
- element.find( ".ui-state-active a" ).eq( 1 ).click();
+ element.find( ".ui-state-active .ui-tabs-anchor" ).eq( 1 ).click();
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
});
@@ -131,7 +131,7 @@ test( "{ collapsible: true }", function() {
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
- element.find( ".ui-state-active a" ).click();
+ element.find( ".ui-state-active .ui-tabs-anchor" ).click();
equal( element.tabs( "option", "active" ), false );
state( element, 0, 0, 0 );
});
@@ -173,7 +173,7 @@ test( "{ event: null }", function() {
state( element, 0, 1, 0 );
// ensure default click handler isn't bound
- element.find( ".ui-tabs-nav a" ).eq( 2 ).click();
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).click();
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
});
@@ -186,27 +186,27 @@ test( "{ event: custom }", function() {
});
state( element, 1, 0, 0 );
- element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" );
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom1" );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
// ensure default click handler isn't bound
- element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "click" );
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
- element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "custom2" );
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "custom2" );
equal( element.tabs( "option", "active" ), 2 );
state( element, 0, 0, 1 );
element.tabs( "option", "event", "custom3" );
// ensure old event handlers are unbound
- element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" );
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom1" );
equal( element.tabs( "option", "active" ), 2 );
state( element, 0, 0, 1 );
- element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom3" );
+ element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom3" );
equal( element.tabs( "option", "active" ), 1 );
state( element, 0, 1, 0 );
});
diff --git a/tests/unit/tabs/tabs_test_helpers.js b/tests/unit/tabs/tabs_test_helpers.js
index 9f592c074..508043943 100644
--- a/tests/unit/tabs/tabs_test_helpers.js
+++ b/tests/unit/tabs/tabs_test_helpers.js
@@ -43,7 +43,7 @@ TestHelpers.tabs = {
actual = tabs.find( ".ui-tabs-nav li" ).map(function() {
var tab = $( this ),
panel = $( $.ui.tabs.prototype._sanitizeSelector(
- "#" + tab.find( "a" ).attr( "aria-controls" ) ) ),
+ "#" + tab.attr( "aria-controls" ) ) ),
tabIsActive = tab.hasClass( "ui-state-active" ),
panelIsActive = panel.css( "display" ) !== "none";
diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html
index d20ba8578..f6e60b367 100644
--- a/tests/unit/tooltip/tooltip.html
+++ b/tests/unit/tooltip/tooltip.html
@@ -41,6 +41,7 @@
<div>
<a id="tooltipped1" href="#" title="anchortitle">anchor</a>
<input title="inputtitle">
+ <span id="multiple-describedby" aria-describedby="fixture-span" title="...">aria-describedby</span>
<span id="fixture-span" title="title-text">span</span>
</div>
diff --git a/tests/unit/tooltip/tooltip_core.js b/tests/unit/tooltip/tooltip_core.js
index e2569fb01..1c8817aa8 100644
--- a/tests/unit/tooltip/tooltip_core.js
+++ b/tests/unit/tooltip/tooltip_core.js
@@ -3,7 +3,7 @@
module( "tooltip: core" );
test( "markup structure", function() {
- expect( 6 );
+ expect( 7 );
var element = $( "#tooltipped1" ).tooltip(),
tooltip = $( ".ui-tooltip" );
@@ -11,8 +11,9 @@ test( "markup structure", function() {
equal( tooltip.length, 0, "no tooltip on init" );
element.tooltip( "open" );
- tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
equal( tooltip.length, 1, "tooltip exists" );
+ equal( element.attr( "aria-describedby"), tooltip.attr( "id" ), "aria-describedby" );
ok( tooltip.hasClass( "ui-tooltip" ), "tooltip is .ui-tooltip" );
equal( tooltip.length, 1, ".ui-tooltip exists" );
equal( tooltip.find( ".ui-tooltip-content" ).length, 1,
@@ -20,8 +21,24 @@ test( "markup structure", function() {
});
test( "accessibility", function() {
- // TODO: add tests
- expect( 0 );
+ expect( 5 );
+
+ var tooltipId,
+ tooltip,
+ element = $( "#multiple-describedby" ).tooltip();
+
+ element.tooltip( "open" );
+ tooltipId = element.data( "ui-tooltip-id" );
+ tooltip = $( "#" + tooltipId );
+ equal( tooltip.attr( "role" ), "tooltip", "role" );
+ equal( element.attr( "aria-describedby" ), "fixture-span " + tooltipId,
+ "multiple describedby when open" );
+ // strictEqual to distinguish between .removeAttr( "title" ) and .attr( "title", "" )
+ strictEqual( element.attr( "title" ), undefined, "no title when open" );
+ element.tooltip( "close" );
+ equal( element.attr( "aria-describedby" ), "fixture-span",
+ "correct describedby when closed" );
+ equal( element.attr( "title" ), "...", "title restored when closed" );
});
}( jQuery ) );
diff --git a/tests/unit/tooltip/tooltip_events.js b/tests/unit/tooltip/tooltip_events.js
index b1ce92fb2..fc5f1acc5 100644
--- a/tests/unit/tooltip/tooltip_events.js
+++ b/tests/unit/tooltip/tooltip_events.js
@@ -11,7 +11,7 @@ test( "programmatic triggers", function() {
tooltip = ui.tooltip;
ok( !( "originalEvent" in event ), "open" );
strictEqual( ui.tooltip[0],
- $( "#" + element.attr( "aria-describedby" ) )[0], "ui.tooltip" );
+ $( "#" + element.data( "ui-tooltip-id" ) )[0], "ui.tooltip" );
});
element.tooltip( "open" );
diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js
index eaab1c0d1..1b8cd2bf2 100644
--- a/tests/unit/tooltip/tooltip_methods.js
+++ b/tests/unit/tooltip/tooltip_methods.js
@@ -21,7 +21,7 @@ test( "open/close", function() {
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
element.tooltip( "open" );
- tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
ok( tooltip.is( ":visible" ) );
element.tooltip( "close" );
@@ -37,7 +37,7 @@ test( "enable/disable", function() {
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
element.tooltip( "open" );
- tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
ok( tooltip.is( ":visible" ) );
element.tooltip( "disable" );
@@ -51,7 +51,7 @@ test( "enable/disable", function() {
equal( element.attr( "title" ), "anchortitle", "title restored on enable" );
element.tooltip( "open" );
- tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
ok( tooltip.is( ":visible" ) );
$.fx.off = false;
});
diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js
index 4f994f8de..a4ef9f472 100644
--- a/tests/unit/tooltip/tooltip_options.js
+++ b/tests/unit/tooltip/tooltip_options.js
@@ -4,7 +4,7 @@ module( "tooltip: options" );
test( "content: default", function() {
var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
- deepEqual( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
+ deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "anchortitle" );
});
test( "content: return string", function() {
@@ -13,7 +13,7 @@ test( "content: return string", function() {
return "customstring";
}
}).tooltip( "open" );
- deepEqual( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
+ deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" );
});
test( "content: return jQuery", function() {
@@ -22,7 +22,7 @@ test( "content: return jQuery", function() {
return $( "<div>" ).html( "cu<b>s</b>tomstring" );
}
}).tooltip( "open" );
- deepEqual( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
+ deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" );
});
asyncTest( "content: sync + async callback", function() {
@@ -30,11 +30,11 @@ asyncTest( "content: sync + async callback", function() {
var element = $( "#tooltipped1" ).tooltip({
content: function( response ) {
setTimeout(function() {
- deepEqual( $( "#" + element.attr("aria-describedby") ).text(), "loading..." );
+ deepEqual( $( "#" + element.data("ui-tooltip-id") ).text(), "loading..." );
response( "customstring2" );
setTimeout(function() {
- deepEqual( $( "#" + element.attr("aria-describedby") ).text(), "customstring2" );
+ deepEqual( $( "#" + element.data("ui-tooltip-id") ).text(), "customstring2" );
start();
}, 13 );
}, 13 );
@@ -53,12 +53,12 @@ test( "items", function() {
event = $.Event( "mouseenter" );
event.target = $( "#fixture-span" )[ 0 ];
element.tooltip( "open", event );
- deepEqual( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
+ deepEqual( $( "#" + $( "#fixture-span" ).data( "ui-tooltip-id" ) ).text(), "title-text" );
// make sure default [title] doesn't get used
event.target = $( "#tooltipped1" )[ 0 ];
element.tooltip( "open", event );
- deepEqual( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined );
+ deepEqual( $( "#tooltipped1" ).data( "ui-tooltip-id" ), undefined );
element.tooltip( "destroy" );
});
@@ -68,7 +68,7 @@ test( "tooltipClass", function() {
var element = $( "#tooltipped1" ).tooltip({
tooltipClass: "custom"
}).tooltip( "open" );
- ok( $( "#" + element.attr( "aria-describedby" ) ).hasClass( "custom" ) );
+ ok( $( "#" + element.data( "ui-tooltip-id" ) ).hasClass( "custom" ) );
});
}( jQuery ) );