aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/tooltip/tooltip_options.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/tooltip/tooltip_options.js')
-rw-r--r--tests/unit/tooltip/tooltip_options.js105
1 files changed, 56 insertions, 49 deletions
diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js
index 37a468489..04bb4c6a4 100644
--- a/tests/unit/tooltip/tooltip_options.js
+++ b/tests/unit/tooltip/tooltip_options.js
@@ -1,66 +1,73 @@
-/*
- * tooltip_options.js
- */
-(function($) {
-
-module("tooltip: options", {
- teardown: function() {
- $(":ui-tooltip").tooltip("destroy");
- }
-});
+(function( $ ) {
+module( "tooltip: options" );
-test("option: items", function() {
- var event = $.Event("mouseenter");
- event.target = $("[data-tooltip]");
- $("#qunit-fixture").tooltip({
- items: "[data-tooltip]",
- content: function() {
- return $(this).attr("data-tooltip");
- }
- }).tooltip("open", event);
- same( $( "#" + $("#fixture-span").attr("aria-describedby") ).text(), "text" );
+test( "content: default", function() {
+ var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
+ same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
});
-test("content: default", function() {
- $("#tooltipped1").tooltip().tooltip("open");
- same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "anchortitle" );
-});
-
-test("content: return string", function() {
- $("#tooltipped1").tooltip({
+test( "content: return string", function() {
+ var element = $( "#tooltipped1" ).tooltip({
content: function() {
return "customstring";
}
- }).tooltip("open");
- same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" );
+ }).tooltip( "open" );
+ same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
});
-test("content: return jQuery", function() {
- $("#tooltipped1").tooltip({
+test( "content: return jQuery", function() {
+ var element = $( "#tooltipped1" ).tooltip({
content: function() {
- return $("<div></div>").html("cu<b>s</b>tomstring");
+ return $( "<div>" ).html( "cu<b>s</b>tomstring" );
}
- }).tooltip("open");
- same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" );
+ }).tooltip( "open" );
+ 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" );
+});
+
+test( "items", function() {
+ expect( 2 );
+ var element = $( "#qunit-fixture" ).tooltip({
+ 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" );
+});
+
+test( "tooltipClass", function() {
+ expect( 1 )
+ var element = $( "#tooltipped1" ).tooltip({
+ tooltipClass: "custom"
+ }).tooltip( "open" );
+ ok( $( "#" + element.attr( "aria-describedby" ) ).hasClass( "custom" ) );
});
-*/
-})(jQuery);
+}( jQuery ) );