aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-01-24 21:54:50 -0500
committerScott González <scott.gonzalez@gmail.com>2011-01-24 21:54:50 -0500
commit0ef4b4f28a8183051fdaae7d896c09efbbecb0f9 (patch)
treef6e1d61fe82d51db63d65dd26eae4adf3a42a688 /tests
parent711df1f5e54062d090d92f4e630e4cb0cc137b21 (diff)
downloadjquery-ui-0ef4b4f28a8183051fdaae7d896c09efbbecb0f9.tar.gz
jquery-ui-0ef4b4f28a8183051fdaae7d896c09efbbecb0f9.zip
Widget: Added tests for ._hoverable() and ._focusable().
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/widget/widget_core.js66
1 files changed, 64 insertions, 2 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 5ed0717da..b701193cf 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -404,7 +404,7 @@ test( ".widget() - overriden", function() {
same( wrapper[0], $( "<div></div>" ).testWidget().testWidget( "widget" )[0] );
});
-test( "_bind to element (default)", function() {
+test( "._bind() to element (default)", function() {
expect( 12 );
var self;
$.widget( "ui.testWidget", {
@@ -444,7 +444,7 @@ test( "_bind to element (default)", function() {
.trigger( "keydown" );
});
-test( "_bind to descendent", function() {
+test( "._bind() to descendent", function() {
expect( 12 );
var self;
$.widget( "ui.testWidget", {
@@ -497,6 +497,68 @@ test( "_bind to descendent", function() {
.trigger( "keydown" );
});
+test( "._hoverable()", function() {
+ $.widget( "ui.testWidget", {
+ _create: function() {
+ this._hoverable( this.element.children() );
+ }
+ });
+
+ var div = $( "#widget" ).testWidget().children();
+ ok( !div.hasClass( "ui-state-hover" ), "not hovered on init" );
+ div.trigger( "mouseenter" );
+ ok( div.hasClass( "ui-state-hover" ), "hovered after mouseenter" );
+ div.trigger( "mouseleave" );
+ ok( !div.hasClass( "ui-state-hover" ), "not hovered after mouseleave" );
+
+ div.trigger( "mouseenter" );
+ ok( div.hasClass( "ui-state-hover" ), "hovered after mouseenter" );
+ $( "#widget" ).testWidget( "disable" );
+ ok( !div.hasClass( "ui-state-hover" ), "not hovered while disabled" );
+ div.trigger( "mouseenter" );
+ ok( !div.hasClass( "ui-state-hover" ), "can't hover while disabled" );
+ $( "#widget" ).testWidget( "enable" );
+ ok( !div.hasClass( "ui-state-hover" ), "enabling doesn't reset hover" );
+
+ div.trigger( "mouseenter" );
+ ok( div.hasClass( "ui-state-hover" ), "hovered after mouseenter" );
+ $( "#widget" ).testWidget( "destroy" );
+ ok( !div.hasClass( "ui-state-hover" ), "not hovered after destroy" );
+ div.trigger( "mouseenter" );
+ ok( !div.hasClass( "ui-state-hover" ), "event handler removed on destroy" );
+});
+
+test( "._focusable()", function() {
+ $.widget( "ui.testWidget", {
+ _create: function() {
+ this._focusable( this.element.children() );
+ }
+ });
+
+ var div = $( "#widget" ).testWidget().children();
+ ok( !div.hasClass( "ui-state-focus" ), "not focused on init" );
+ div.trigger( "focus" );
+ ok( div.hasClass( "ui-state-focus" ), "focused after explicit focus" );
+ div.trigger( "blur" );
+ ok( !div.hasClass( "ui-state-focus" ), "not focused after blur" );
+
+ div.trigger( "focus" );
+ ok( div.hasClass( "ui-state-focus" ), "focused after explicit focus" );
+ $( "#widget" ).testWidget( "disable" );
+ ok( !div.hasClass( "ui-state-focus" ), "not focused while disabled" );
+ div.trigger( "focus" );
+ ok( !div.hasClass( "ui-state-focus" ), "can't focus while disabled" );
+ $( "#widget" ).testWidget( "enable" );
+ ok( !div.hasClass( "ui-state-focus" ), "enabling doesn't reset focus" );
+
+ div.trigger( "focus" );
+ ok( div.hasClass( "ui-state-focus" ), "focused after explicit focus" );
+ $( "#widget" ).testWidget( "destroy" );
+ ok( !div.hasClass( "ui-state-focus" ), "not focused after destroy" );
+ div.trigger( "focus" );
+ ok( !div.hasClass( "ui-state-focus" ), "event handler removed on destroy" );
+});
+
test( "._trigger() - no event, no ui", function() {
expect( 7 );
var handlers = [];