aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-05-28 16:20:46 -0400
committerScott González <scott.gonzalez@gmail.com>2011-05-28 16:20:46 -0400
commit666b53a90c70f9689956ee32f208cace021c42a9 (patch)
tree786bbe1978a563c141960e304f02fbcdca04d64d /tests
parent2fbd310a159c4f5d54a38b406bb559dc1fb35449 (diff)
downloadjquery-ui-666b53a90c70f9689956ee32f208cace021c42a9.tar.gz
jquery-ui-666b53a90c70f9689956ee32f208cace021c42a9.zip
Tooltip tests: Refactored and added some tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/tooltip/tooltip_events.js62
-rw-r--r--tests/unit/tooltip/tooltip_methods.js20
2 files changed, 47 insertions, 35 deletions
diff --git a/tests/unit/tooltip/tooltip_events.js b/tests/unit/tooltip/tooltip_events.js
index 287c39073..515760b28 100644
--- a/tests/unit/tooltip/tooltip_events.js
+++ b/tests/unit/tooltip/tooltip_events.js
@@ -4,45 +4,47 @@ module( "tooltip: events" );
test( "programmatic triggers", function() {
expect( 2 );
- var element = $( "#tooltipped1" ).tooltip({
- open: function( event, ui ) {
- same( event.type, "tooltipopen" );
- },
- close: function( event, ui ) {
- same( event.type, "tooltipclose" );
- }
+ var element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event ) {
+ ok( !( "originalEvent" in event ), "open" );
+ });
+ element.tooltip( "open" );
+
+ element.one( "tooltipclose", function( event ) {
+ ok( !( "originalEvent" in event ), "close" );
});
- element.tooltip( "open" ).tooltip( "close" );
+ element.tooltip( "close" );
});
test( "mouse events", function() {
- expect( 4 );
- var element = $( "#tooltipped1" ).tooltip({
- open: function( event, ui ) {
- same( event.type, "tooltipopen" );
- same( event.originalEvent.type, "mouseover" );
- },
- close: function( event, ui ) {
- same( event.type, "tooltipclose" );
- same( event.originalEvent.type, "mouseleave" );
- }
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event ) {
+ same( event.originalEvent.type, "mouseover" );
});
- element.trigger( "mouseover" ).trigger( "mouseleave" );
+ element.trigger( "mouseover" );
+
+ element.one( "tooltipclose", function( event ) {
+ same( event.originalEvent.type, "mouseleave" );
+ });
+ element.trigger( "mouseleave" );
});
test( "focus events", function() {
- expect( 4 );
- var element = $( "#tooltipped1" ).tooltip({
- open: function( event, ui ) {
- same( event.type, "tooltipopen" );
- same( event.originalEvent.type, "focusin" );
- },
- close: function( event, ui ) {
- same( event.type, "tooltipclose" );
- same( event.originalEvent.type, "blur" );
- }
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event ) {
+ same( event.originalEvent.type, "focusin" );
+ });
+ element.trigger( "focusin" );
+
+ element.one( "tooltipclose", function( event ) {
+ same( event.originalEvent.type, "blur" );
});
- element.trigger( "focus" ).trigger( "blur" );
+ element.trigger( "blur" );
});
}( jQuery ) );
diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js
index cb99ea457..1487672cb 100644
--- a/tests/unit/tooltip/tooltip_methods.js
+++ b/tests/unit/tooltip/tooltip_methods.js
@@ -3,15 +3,25 @@
module( "tooltip: methods" );
test( "destroy", function() {
- var beforeHtml = $( "#tooltipped1" ).parent().html();
- var afterHtml = $( "#tooltipped1" ).tooltip().tooltip( "destroy" ).parent().html();
- equal( afterHtml, beforeHtml );
+ domEqual( "#tooltipped1", function() {
+ $( "#tooltipped1" ).tooltip().tooltip( "destroy" );
+ });
});
-test( "open", function() {
+test( "open/close", function() {
+ expect( 3 );
+ $.fx.off = true;
var element = $( "#tooltipped1" ).tooltip();
+ equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
+$( ".ui-tooltip" ).each(function() {
+ console.log( $( this ).html() );
+});
element.tooltip( "open" );
- ok( $( ".ui-tooltip" ).is( ":visible" ) );
+ var tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ ok( tooltip.is( ":visible" ) );
+ element.tooltip( "close" );
+ ok( tooltip.is( ":hidden" ) );
+ $.fx.off = false;
});
/*