]> source.dussan.org Git - jquery-ui.git/commitdiff
Tooltip tests: Coding standards.
authorScott González <scott.gonzalez@gmail.com>
Sat, 28 May 2011 17:30:00 +0000 (13:30 -0400)
committerScott González <scott.gonzalez@gmail.com>
Sat, 28 May 2011 17:30:00 +0000 (13:30 -0400)
tests/unit/tooltip/tooltip.html
tests/unit/tooltip/tooltip_core.js
tests/unit/tooltip/tooltip_defaults.js
tests/unit/tooltip/tooltip_events.js
tests/unit/tooltip/tooltip_methods.js
tests/unit/tooltip/tooltip_options.js

index 189c75261f3013639c2949f9a8398a086780fc82..d540504abc467a1fb0a93e65e0cbc8a1ad9bc644 100644 (file)
@@ -1,30 +1,29 @@
-<!DOCTYPE html>
+<!doctype html>
 <html lang="en">
 <head>
-       <meta charset="UTF-8" />
+       <meta charset="utf-8">
        <title>jQuery UI Tooltip Test Suite</title>
 
-       <link type="text/css" href="../../../themes/base/jquery.ui.tooltip.css" rel="stylesheet" />
-
-       <script type="text/javascript" src="../../../jquery-1.5.1.js"></script>
-       <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
-       <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
-       <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
-       <script type="text/javascript" src="../../../ui/jquery.ui.tooltip.js"></script>
-
-       <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
-       <script type="text/javascript" src="../../../external/qunit.js"></script>
-       <script type="text/javascript" src="../../jquery.simulate.js"></script>
-       <script type="text/javascript" src="../testsuite.js"></script>
-       
-       <script type="text/javascript" src="tooltip_core.js"></script>
-       <script type="text/javascript" src="tooltip_defaults.js"></script>
-       <script type="text/javascript" src="tooltip_events.js"></script>
-       <script type="text/javascript" src="tooltip_methods.js"></script>
-       <script type="text/javascript" src="tooltip_options.js"></script>
-
-       <script type="text/javascript" src="../swarminject.js"></script>
-       
+       <link rel="stylesheet" href="../../../themes/base/jquery.ui.tooltip.css">
+
+       <script src="../../../jquery-1.5.1.js"></script>
+       <script src="../../../ui/jquery.ui.core.js"></script>
+       <script src="../../../ui/jquery.ui.widget.js"></script>
+       <script src="../../../ui/jquery.ui.position.js"></script>
+       <script src="../../../ui/jquery.ui.tooltip.js"></script>
+
+       <link rel="stylesheet" href="../../../external/qunit.css">
+       <script src="../../../external/qunit.js"></script>
+       <script src="../../jquery.simulate.js"></script>
+       <script src="../testsuite.js"></script>
+
+       <script src="tooltip_defaults.js"></script>
+       <script src="tooltip_core.js"></script>
+       <script src="tooltip_events.js"></script>
+       <script src="tooltip_methods.js"></script>
+       <script src="tooltip_options.js"></script>
+
+       <script src="../swarminject.js"></script>
 </head>
 <body>
 
 <h2 id="qunit-banner"></h2>
 <div id="qunit-testrunner-toolbar"></div>
 <h2 id="qunit-userAgent"></h2>
-<ol id="qunit-tests">
-</ol>
-
+<ol id="qunit-tests"></ol>
 <div id="qunit-fixture">
-       <div>
-               <a id="tooltipped1" href="#" title="anchortitle">anchor</a>
-               <input title="inputtitle" />
-               <span id="fixture-span" data-tooltip="text">span</span>
-       </div>
+
+<div>
+       <a id="tooltipped1" href="#" title="anchortitle">anchor</a>
+       <input title="inputtitle">
+       <span id="fixture-span" data-tooltip="text">span</span>
 </div>
 
+</div>
 </body>
 </html>
index 247927df4f773b2aa50c85288b3533a7cc1a4a62..055a2927f2ea31deb6ae700b9d8241c78c104deb 100644 (file)
@@ -1,11 +1,7 @@
-/*
- * tooltip_core.js
- */
+(function( $ ) {
 
+module( "tooltip: core" );
 
-(function($) {
 
-module("tooltip: core");
 
-
-})(jQuery);
+}( jQuery ) );
index 5f304f497f990da408f509c6d9855c55beafef76..317ba1aa0d8471ed50ac89421e29a81f242dcf29 100644 (file)
@@ -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"
index 5c915ae30995d44624a2f9d9cb6088e418ce83e9..287c390731cf4fe52810e878350854b3849b4e28 100644 (file)
@@ -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 ) );
index 496a5fdb793a6cae72a02b769577dab5326e4366..cb99ea457c517326e4f1c52b4f180b180ff3a33d 100644 (file)
@@ -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 ) );
index 37a468489df0de2605edf197ce7c8e4582c347f8..c9f92c5275c5161b0bad1557e8348d6e531d92ce 100644 (file)
@@ -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 $("<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" );
 });
 
 /*
@@ -63,4 +56,4 @@ test("content: callback string", function() {
 });
 */
 
-})(jQuery);
+}( jQuery ) );