Tooltip tests: Coding standards.

This commit is contained in:
Scott González 2011-05-28 13:30:00 -04:00
parent d43118dfba
commit 73c6f349fc
6 changed files with 85 additions and 110 deletions

View 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" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.tooltip.css">
<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>
<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" 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>
<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 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>
<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>
@ -32,16 +31,15 @@
<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" />
<input title="inputtitle">
<span id="fixture-span" data-tooltip="text">span</span>
</div>
</div>
</div>
</body>
</html>

View File

@ -1,11 +1,7 @@
/*
* tooltip_core.js
*/
(function( $ ) {
module( "tooltip: core" );
})(jQuery);
}( jQuery ) );

View 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"

View File

@ -1,13 +1,10 @@
/*
* tooltip_events.js
*/
(function( $ ) {
module( "tooltip: events" );
test( "programmatic triggers", function() {
expect( 2 );
var e = $("#tooltipped1").tooltip({
var element = $( "#tooltipped1" ).tooltip({
open: function( event, ui ) {
same( event.type, "tooltipopen" );
},
@ -15,13 +12,12 @@ test("programmatic triggers", function() {
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({
var element = $( "#tooltipped1" ).tooltip({
open: function( event, ui ) {
same( event.type, "tooltipopen" );
same( event.originalEvent.type, "mouseover" );
@ -31,13 +27,12 @@ test("mouse events", function() {
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({
var element = $( "#tooltipped1" ).tooltip({
open: function( event, ui ) {
same( event.type, "tooltipopen" );
same( event.originalEvent.type, "focusin" );
@ -47,8 +42,7 @@ test("focus events", function() {
same( event.originalEvent.type, "blur" );
}
});
e.trigger("focus").trigger("blur");
e.tooltip("destroy");
element.trigger( "focus" ).trigger( "blur" );
});
})(jQuery);
}( jQuery ) );

View File

@ -1,9 +1,5 @@
/*
* tooltip_methods.js
*/
(function( $ ) {
module( "tooltip: methods" );
test( "destroy", function() {
@ -13,10 +9,9 @@ test("destroy", function() {
});
test( "open", function() {
var e = $("#tooltipped1").tooltip();
e.tooltip("open");
var element = $( "#tooltipped1" ).tooltip();
element.tooltip( "open" );
ok( $( ".ui-tooltip" ).is( ":visible" ) );
$(":ui-tooltip").tooltip("destroy");
});
/*
@ -29,5 +24,4 @@ test("widget", function() {
});
*/
})(jQuery);
}( jQuery ) );

View File

@ -1,48 +1,41 @@
/*
* tooltip_options.js
*/
(function( $ ) {
module("tooltip: options", {
teardown: function() {
$(":ui-tooltip").tooltip("destroy");
}
});
module( "tooltip: options" );
test("option: items", function() {
test( "items", function() {
var event = $.Event( "mouseenter" );
event.target = $("[data-tooltip]");
$("#qunit-fixture").tooltip({
event.target = $( "[data-tooltip]" )[ 0 ];
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" );
element.tooltip( "destroy" );
});
test( "content: default", function() {
$("#tooltipped1").tooltip().tooltip("open");
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "anchortitle" );
var element = $( "#tooltipped1" ).tooltip().tooltip("open");
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
});
test( "content: return string", function() {
$("#tooltipped1").tooltip({
var element = $( "#tooltipped1" ).tooltip({
content: function() {
return "customstring";
}
}).tooltip( "open" );
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" );
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
});
test( "content: return jQuery", function() {
$("#tooltipped1").tooltip({
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" );
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
});
/*
@ -63,4 +56,4 @@ test("content: callback string", function() {
});
*/
})(jQuery);
}( jQuery ) );