From 73c6f349fcdd83d838df91e5ce4bc524e8dd989d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Sat, 28 May 2011 13:30:00 -0400 Subject: [PATCH] Tooltip tests: Coding standards. --- tests/unit/tooltip/tooltip.html | 60 +++++++++++++------------- tests/unit/tooltip/tooltip_core.js | 10 ++--- tests/unit/tooltip/tooltip_defaults.js | 2 +- tests/unit/tooltip/tooltip_events.js | 48 +++++++++------------ tests/unit/tooltip/tooltip_methods.js | 26 +++++------ tests/unit/tooltip/tooltip_options.js | 53 ++++++++++------------- 6 files changed, 87 insertions(+), 112 deletions(-) diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html index 189c75261..d540504ab 100644 --- a/tests/unit/tooltip/tooltip.html +++ b/tests/unit/tooltip/tooltip.html @@ -1,30 +1,29 @@ - + - + jQuery UI Tooltip Test Suite - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -32,16 +31,15 @@

-
    -
- +
    -
    - anchor - - span -
    + +
    + anchor + + span
    +
    diff --git a/tests/unit/tooltip/tooltip_core.js b/tests/unit/tooltip/tooltip_core.js index 247927df4..055a2927f 100644 --- a/tests/unit/tooltip/tooltip_core.js +++ b/tests/unit/tooltip/tooltip_core.js @@ -1,11 +1,7 @@ -/* - * tooltip_core.js - */ +(function( $ ) { +module( "tooltip: core" ); -(function($) { -module("tooltip: core"); - -})(jQuery); +}( jQuery ) ); diff --git a/tests/unit/tooltip/tooltip_defaults.js b/tests/unit/tooltip/tooltip_defaults.js index 5f304f497..317ba1aa0 100644 --- a/tests/unit/tooltip/tooltip_defaults.js +++ b/tests/unit/tooltip/tooltip_defaults.js @@ -2,7 +2,7 @@ commonWidgetTests( "tooltip", { defaults: { disabled: false, items: "[title]", - content: $.ui.tooltip.prototype.options.content, + content: function() {}, position: { my: "left+15 center", at: "right center" diff --git a/tests/unit/tooltip/tooltip_events.js b/tests/unit/tooltip/tooltip_events.js index 5c915ae30..287c39073 100644 --- a/tests/unit/tooltip/tooltip_events.js +++ b/tests/unit/tooltip/tooltip_events.js @@ -1,54 +1,48 @@ -/* - * tooltip_events.js - */ -(function($) { +(function( $ ) { -module("tooltip: events"); +module( "tooltip: events" ); -test("programmatic triggers", function() { - expect(2); - var e = $("#tooltipped1").tooltip({ - open: function(event, ui) { +test( "programmatic triggers", function() { + expect( 2 ); + var element = $( "#tooltipped1" ).tooltip({ + open: function( event, ui ) { same( event.type, "tooltipopen" ); }, - close: function(event, ui) { + close: function( event, ui ) { same( event.type, "tooltipclose" ); } }); - e.tooltip("open").tooltip("close"); - e.tooltip("destroy"); + element.tooltip( "open" ).tooltip( "close" ); }); -test("mouse events", function() { - expect(4); - var e = $("#tooltipped1").tooltip({ - open: function(event, ui) { +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) { + close: function( event, ui ) { same( event.type, "tooltipclose" ); same( event.originalEvent.type, "mouseleave" ); } }); - e.trigger("mouseover").trigger("mouseleave"); - e.tooltip("destroy"); + element.trigger( "mouseover" ).trigger( "mouseleave" ); }); -test("focus events", function() { - expect(4); - var e = $("#tooltipped1").tooltip({ - open: function(event, ui) { +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) { + close: function( event, ui ) { same( event.type, "tooltipclose" ); same( event.originalEvent.type, "blur" ); } }); - e.trigger("focus").trigger("blur"); - e.tooltip("destroy"); + element.trigger( "focus" ).trigger( "blur" ); }); -})(jQuery); +}( jQuery ) ); diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index 496a5fdb7..cb99ea457 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -1,22 +1,17 @@ -/* - * tooltip_methods.js - */ -(function($) { - +(function( $ ) { -module("tooltip: methods"); +module( "tooltip: methods" ); -test("destroy", function() { - var beforeHtml = $("#tooltipped1").parent().html(); - var afterHtml = $("#tooltipped1").tooltip().tooltip("destroy").parent().html(); +test( "destroy", function() { + var beforeHtml = $( "#tooltipped1" ).parent().html(); + var afterHtml = $( "#tooltipped1" ).tooltip().tooltip( "destroy" ).parent().html(); equal( afterHtml, beforeHtml ); }); -test("open", function() { - var e = $("#tooltipped1").tooltip(); - e.tooltip("open"); - ok( $(".ui-tooltip").is(":visible") ); - $(":ui-tooltip").tooltip("destroy"); +test( "open", function() { + var element = $( "#tooltipped1" ).tooltip(); + element.tooltip( "open" ); + ok( $( ".ui-tooltip" ).is( ":visible" ) ); }); /* @@ -29,5 +24,4 @@ test("widget", function() { }); */ - -})(jQuery); +}( jQuery ) ); diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index 37a468489..c9f92c527 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -1,48 +1,41 @@ -/* - * 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({ +test( "items", function() { + var event = $.Event( "mouseenter" ); + event.target = $( "[data-tooltip]" )[ 0 ]; + var element = $( "#qunit-fixture" ).tooltip({ items: "[data-tooltip]", content: function() { - return $(this).attr("data-tooltip"); + return $( this ).attr( "data-tooltip" ); } - }).tooltip("open", event); - same( $( "#" + $("#fixture-span").attr("aria-describedby") ).text(), "text" ); + }).tooltip( "open", event ); + same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "text" ); + element.tooltip( "destroy" ); }); -test("content: default", function() { - $("#tooltipped1").tooltip().tooltip("open"); - same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "anchortitle" ); +test( "content: default", function() { + var element = $( "#tooltipped1" ).tooltip().tooltip("open"); + same( $( "#" + element.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 $("
    ").html("customstring"); + return $( "
    " ).html( "customstring" ); } - }).tooltip("open"); - same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" ); + }).tooltip( "open" ); + same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" ); }); /* @@ -63,4 +56,4 @@ test("content: callback string", function() { }); */ -})(jQuery); +}( jQuery ) ); -- 2.39.5