aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/button
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/button')
-rw-r--r--tests/unit/button/button_core.js72
-rw-r--r--tests/unit/button/button_events.js20
-rw-r--r--tests/unit/button/button_options.js11
-rw-r--r--tests/unit/button/button_tickets.js75
4 files changed, 96 insertions, 82 deletions
diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js
index d53dedf90..6d0bbbe88 100644
--- a/tests/unit/button/button_core.js
+++ b/tests/unit/button/button_core.js
@@ -92,7 +92,7 @@ test("buttonset (rtl)", function() {
// remove this when simulate properly simulates this
// see http://yuilibrary.com/projects/yui2/ticket/2528826 fore more info
if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
- test( "ensure checked and aria after single click on checkbox label button, see #5518", function() {
+ asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function() {
expect( 3 );
$("#check2").button().change( function() {
@@ -100,8 +100,76 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
ok( this.checked, "checked ok" );
ok( lbl.attr("aria-pressed") === "true", "aria ok" );
ok( lbl.hasClass("ui-state-active"), "ui-state-active ok" );
- }).button("widget").simulate("mousedown").simulate("click").simulate("mouseup");
+ });
+
+ // support: Opera
+ // Opera doesn't trigger a change event when this is done synchronously.
+ // This seems to be a side effect of another test, but until that can be
+ // tracked down, this delay will have to do.
+ setTimeout(function() {
+ $("#check2").button("widget").simulate("click");
+ start();
+ }, 1 );
});
}
+test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
+ expect( 5 );
+ var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
+ 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[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[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[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[type=checkbox]" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ) );
+});
+
+test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
+ expect( 2 );
+ $( "#radio01" ).next().andSelf().hide();
+ 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" ) );
+});
+
+test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
+ expect( 3 );
+ $( "#radio0" ).hide();
+ var set = $( "#radio0" ).buttonset();
+ ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
+ ok( set.find( "label:eq(1)" ).is( ".ui-button" ) );
+ ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
+});
+
+asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
+ expect( 2 );
+ var check = $( "#check" ).button(),
+ label = $( "label[for='check']" );
+ ok( !label.is( ".ui-state-focus" ) );
+ check.focus();
+ setTimeout(function() {
+ ok( label.is( ".ui-state-focus" ) );
+ start();
+ });
+});
+
+test( "#7534 - Button label selector works for ids with \":\"", function() {
+ expect( 1 );
+ var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
+ group.find( "input" ).button();
+ ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
+});
+
})(jQuery);
diff --git a/tests/unit/button/button_events.js b/tests/unit/button/button_events.js
index 7b79c41ea..2fd038325 100644
--- a/tests/unit/button/button_events.js
+++ b/tests/unit/button/button_events.js
@@ -13,14 +13,24 @@ test("buttonset works with single-quote named elements (#7505)", function() {
}).click();
});
-test( "when button loses focus, ensure active state is removed (#8559)", function() {
+asyncTest( "when button loses focus, ensure active state is removed (#8559)", function() {
expect( 1 );
- $("#button").button().keypress( function() {
- $("#button").one( "blur", function() {
- ok( !$("#button").is(".ui-state-active"), "button loses active state appropriately" );
+ var element = $( "#button" ).button();
+
+ element.one( "keypress", function() {
+ element.one( "blur", function() {
+ ok( !element.is(".ui-state-active"), "button loses active state appropriately" );
+ start();
}).blur();
- }).focus().simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ).simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } );
+ });
+
+ element.focus();
+ setTimeout(function() {
+ element
+ .simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } )
+ .simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } );
+ });
});
})(jQuery);
diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js
index eeb6e5527..e1931a54e 100644
--- a/tests/unit/button/button_options.js
+++ b/tests/unit/button/button_options.js
@@ -103,4 +103,15 @@ test("icons", function() {
$("#button").button("destroy");
});
+test( "#5295 - button does not remove hoverstate if disabled" , function() {
+ expect( 1 );
+ var btn = $("#button").button();
+ btn.hover( function() {
+ btn.button( "disable" );
+ });
+ btn.trigger( "mouseenter" );
+ btn.trigger( "mouseleave" );
+ ok( !btn.is( ".ui-state-hover") );
+});
+
})(jQuery);
diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js
deleted file mode 100644
index 1272d368f..000000000
--- a/tests/unit/button/button_tickets.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * button_tickets.js
- */
-(function( $ ) {
-
-module( "button: tickets" );
-
-test( "#5295 - button does not remove hoverstate if disabled" , function() {
- expect( 1 );
- var btn = $("#button").button();
- btn.hover( function() {
- btn.button( "disable" );
- });
- btn.trigger( "mouseenter" );
- btn.trigger( "mouseleave" );
- ok( !btn.is( ".ui-state-hover") );
-});
-
-test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
- expect( 2 );
- $( "#radio01" ).next().andSelf().hide();
- 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" ) );
-});
-
-test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
- expect( 3 );
- $( "#radio0" ).hide();
- var set = $( "#radio0" ).buttonset();
- ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
- ok( set.find( "label:eq(1)" ).is( ".ui-button" ) );
- ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
-});
-
-test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
- expect( 2 );
- var check = $( "#check" ).button(),
- label = $( "label[for='check']" );
- ok( !label.is( ".ui-state-focus" ) );
- check.focus();
- ok( label.is( ".ui-state-focus" ) );
-});
-
-test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
- expect( 5 );
- var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
- 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[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[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[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[type=checkbox]" ).button();
- ok( group.find( "label" ).is( ".ui-button" ) );
-});
-
-test( "#7534 - Button label selector works for ids with \":\"", function() {
- expect( 1 );
- var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
- group.find( "input" ).button();
- ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
-});
-
-})( jQuery );