diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-05-28 17:36:57 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-05-28 17:36:57 -0400 |
commit | 4dbfdcede3878415dbf5c777e9e2ce17c6916edc (patch) | |
tree | c1ac1a1e003ae1c1a1ff62c40b42ca2944aa69b1 /tests/unit/tooltip/tooltip_options.js | |
parent | c2ae4e3fe4be63906dd5da084cfb7fb812421283 (diff) | |
download | jquery-ui-4dbfdcede3878415dbf5c777e9e2ce17c6916edc.tar.gz jquery-ui-4dbfdcede3878415dbf5c777e9e2ce17c6916edc.zip |
Tooltip: Allow content updates via async response regardless of whether a sync response came back. Added more tests.
Diffstat (limited to 'tests/unit/tooltip/tooltip_options.js')
-rw-r--r-- | tests/unit/tooltip/tooltip_options.js | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index c866d219f..bbbab72ff 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -3,15 +3,21 @@ module( "tooltip: options" ); test( "items", function() { - var event = $.Event( "mouseenter" ); - event.target = $( "[data-tooltip]" )[ 0 ]; + expect( 2 ); var element = $( "#qunit-fixture" ).tooltip({ - items: "[data-tooltip]", - content: function() { - return $( this ).attr( "data-tooltip" ); - } - }).tooltip( "open", event ); - same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "text" ); + items: "#fixture-span" + }); + + var event = $.Event( "mouseenter" ); + event.target = $( "#fixture-span" )[ 0 ]; + element.tooltip( "open", event ); + same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" ); + + // make sure default [title] doesn't get used + event.target = $( "#tooltipped1" )[ 0 ]; + element.tooltip( "open", event ); + same( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined ); + element.tooltip( "destroy" ); }); @@ -38,22 +44,22 @@ test( "content: return jQuery", function() { same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" ); }); -/* -TODO broken, probably related to async content -test("content: callback string", function() { - stop(); - $("#tooltipped1").tooltip({ - content: function(response) { - response("customstring2"); +asyncTest( "content: sync + async callback", function() { + expect( 2 ); + var element = $( "#tooltipped1" ).tooltip({ + content: function( response ) { setTimeout(function() { - //console.log($("#tooltipped1").attr("aria-describedby")) - same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring2" ); - start(); - }, 100) + same( $( "#" + element.attr("aria-describedby") ).text(), "loading..." ); + + response( "customstring2" ); + setTimeout(function() { + same( $( "#" + element.attr("aria-describedby") ).text(), "customstring2" ); + start(); + }, 13 ); + }, 13 ); + return "loading..."; } - }).tooltip("open"); - + }).tooltip( "open" ); }); -*/ }( jQuery ) ); |