jquery-ui/tests/unit/tooltip/tooltip_methods.js

71 lines
1.9 KiB
JavaScript
Raw Normal View History

2011-05-28 17:30:00 +00:00
(function( $ ) {
2011-05-28 17:30:00 +00:00
module( "tooltip: methods" );
2011-05-28 17:30:00 +00:00
test( "destroy", function() {
expect( 2 );
domEqual( "#tooltipped1", function() {
$( "#tooltipped1" ).tooltip().tooltip( "destroy" );
});
// make sure that open tooltips are removed on destroy
$( "#tooltipped1" ).tooltip().tooltip( "open" ).tooltip( "destroy" );
equal( $( ".ui-tooltip" ).length, 0 );
});
test( "open/close", function() {
expect( 3 );
$.fx.off = true;
2012-04-19 02:36:15 +00:00
var tooltip,
element = $( "#tooltipped1" ).tooltip();
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
2011-05-28 17:30:00 +00:00
element.tooltip( "open" );
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
ok( tooltip.is( ":visible" ) );
element.tooltip( "close" );
ok( tooltip.is( ":hidden" ) );
$.fx.off = false;
});
test( "enable/disable", function() {
expect( 7 );
$.fx.off = true;
2012-04-19 02:36:15 +00:00
var tooltip,
element = $( "#tooltipped1" ).tooltip();
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
element.tooltip( "open" );
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
ok( tooltip.is( ":visible" ) );
element.tooltip( "disable" );
equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" );
2012-06-25 18:51:51 +00:00
// support: jQuery <1.6.2
// support: IE <8
// We should use strictEqual( ..., undefined ) when dropping jQuery 1.6.1 support (or IE6/7)
ok( !tooltip.attr( "title" ), "title removed on disable" );
element.tooltip( "open" );
equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" );
element.tooltip( "enable" );
equal( element.attr( "title" ), "anchortitle", "title restored on enable" );
element.tooltip( "open" );
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
ok( tooltip.is( ":visible" ) );
$.fx.off = false;
});
test( "widget", function() {
expect( 2 );
var element = $( "#tooltipped1" ).tooltip(),
widgetElement = element.tooltip( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
});
2011-05-28 17:30:00 +00:00
}( jQuery ) );