2011-05-28 17:30:00 +00:00
|
|
|
(function( $ ) {
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
module( "tooltip: core" );
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 19:43:22 +00:00
|
|
|
test( "markup structure", function() {
|
2012-05-22 15:06:44 +00:00
|
|
|
expect( 7 );
|
2011-05-28 19:43:22 +00:00
|
|
|
var element = $( "#tooltipped1" ).tooltip(),
|
|
|
|
tooltip = $( ".ui-tooltip" );
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 19:43:22 +00:00
|
|
|
equal( element.attr( "aria-describedby" ), undefined, "no aria-describedby on init" );
|
|
|
|
equal( tooltip.length, 0, "no tooltip on init" );
|
|
|
|
|
|
|
|
element.tooltip( "open" );
|
2012-05-22 15:06:44 +00:00
|
|
|
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
|
2011-05-28 19:43:22 +00:00
|
|
|
equal( tooltip.length, 1, "tooltip exists" );
|
2012-05-22 15:06:44 +00:00
|
|
|
equal( element.attr( "aria-describedby"), tooltip.attr( "id" ), "aria-describedby" );
|
2011-05-28 19:43:22 +00:00
|
|
|
ok( tooltip.hasClass( "ui-tooltip" ), "tooltip is .ui-tooltip" );
|
|
|
|
equal( tooltip.length, 1, ".ui-tooltip exists" );
|
|
|
|
equal( tooltip.find( ".ui-tooltip-content" ).length, 1,
|
|
|
|
".ui-tooltip-content exists" );
|
|
|
|
});
|
|
|
|
|
|
|
|
test( "accessibility", function() {
|
2012-05-22 16:54:09 +00:00
|
|
|
expect( 5 );
|
2012-05-22 15:06:44 +00:00
|
|
|
|
|
|
|
var tooltipId,
|
2012-05-22 16:54:09 +00:00
|
|
|
tooltip,
|
2012-05-22 15:06:44 +00:00
|
|
|
element = $( "#multiple-describedby" ).tooltip();
|
|
|
|
|
|
|
|
element.tooltip( "open" );
|
|
|
|
tooltipId = element.data( "ui-tooltip-id" );
|
2012-05-22 16:54:09 +00:00
|
|
|
tooltip = $( "#" + tooltipId );
|
|
|
|
equal( tooltip.attr( "role" ), "tooltip", "role" );
|
2012-05-22 15:06:44 +00:00
|
|
|
equal( element.attr( "aria-describedby" ), "fixture-span " + tooltipId,
|
|
|
|
"multiple describedby when open" );
|
2012-05-22 16:54:09 +00:00
|
|
|
// strictEqual to distinguish between .removeAttr( "title" ) and .attr( "title", "" )
|
|
|
|
strictEqual( element.attr( "title" ), undefined, "no title when open" );
|
2012-05-22 15:06:44 +00:00
|
|
|
element.tooltip( "close" );
|
|
|
|
equal( element.attr( "aria-describedby" ), "fixture-span",
|
|
|
|
"correct describedby when closed" );
|
2012-05-22 16:54:09 +00:00
|
|
|
equal( element.attr( "title" ), "...", "title restored when closed" );
|
2011-05-28 19:43:22 +00:00
|
|
|
});
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
}( jQuery ) );
|