Skip to content

Commit 73c6f34

Browse files
committed
Tooltip tests: Coding standards.
1 parent d43118d commit 73c6f34

File tree

6 files changed

+87
-112
lines changed

6 files changed

+87
-112
lines changed

tests/unit/tooltip/tooltip.html

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
4-
<meta charset="UTF-8" />
4+
<meta charset="utf-8">
55
<title>jQuery UI Tooltip Test Suite</title>
66

7-
<link type="text/css" href="../../../themes/base/jquery.ui.tooltip.css" rel="stylesheet" />
8-
9-
<script type="text/javascript" src="../../../jquery-1.5.1.js"></script>
10-
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
11-
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
12-
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
13-
<script type="text/javascript" src="../../../ui/jquery.ui.tooltip.js"></script>
14-
15-
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
16-
<script type="text/javascript" src="../../../external/qunit.js"></script>
17-
<script type="text/javascript" src="../../jquery.simulate.js"></script>
18-
<script type="text/javascript" src="../testsuite.js"></script>
19-
20-
<script type="text/javascript" src="tooltip_core.js"></script>
21-
<script type="text/javascript" src="tooltip_defaults.js"></script>
22-
<script type="text/javascript" src="tooltip_events.js"></script>
23-
<script type="text/javascript" src="tooltip_methods.js"></script>
24-
<script type="text/javascript" src="tooltip_options.js"></script>
25-
26-
<script type="text/javascript" src="../swarminject.js"></script>
27-
7+
<link rel="stylesheet" href="../../../themes/base/jquery.ui.tooltip.css">
8+
9+
<script src="../../../jquery-1.5.1.js"></script>
10+
<script src="../../../ui/jquery.ui.core.js"></script>
11+
<script src="../../../ui/jquery.ui.widget.js"></script>
12+
<script src="../../../ui/jquery.ui.position.js"></script>
13+
<script src="../../../ui/jquery.ui.tooltip.js"></script>
14+
15+
<link rel="stylesheet" href="../../../external/qunit.css">
16+
<script src="../../../external/qunit.js"></script>
17+
<script src="../../jquery.simulate.js"></script>
18+
<script src="../testsuite.js"></script>
19+
20+
<script src="tooltip_defaults.js"></script>
21+
<script src="tooltip_core.js"></script>
22+
<script src="tooltip_events.js"></script>
23+
<script src="tooltip_methods.js"></script>
24+
<script src="tooltip_options.js"></script>
25+
26+
<script src="../swarminject.js"></script>
2827
</head>
2928
<body>
3029

3130
<h1 id="qunit-header">jQuery UI Tooltip Test Suite</h1>
3231
<h2 id="qunit-banner"></h2>
3332
<div id="qunit-testrunner-toolbar"></div>
3433
<h2 id="qunit-userAgent"></h2>
35-
<ol id="qunit-tests">
36-
</ol>
37-
34+
<ol id="qunit-tests"></ol>
3835
<div id="qunit-fixture">
39-
<div>
40-
<a id="tooltipped1" href="#" title="anchortitle">anchor</a>
41-
<input title="inputtitle" />
42-
<span id="fixture-span" data-tooltip="text">span</span>
43-
</div>
36+
37+
<div>
38+
<a id="tooltipped1" href="#" title="anchortitle">anchor</a>
39+
<input title="inputtitle">
40+
<span id="fixture-span" data-tooltip="text">span</span>
4441
</div>
4542

43+
</div>
4644
</body>
4745
</html>

tests/unit/tooltip/tooltip_core.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
/*
2-
* tooltip_core.js
3-
*/
1+
(function( $ ) {
42

3+
module( "tooltip: core" );
54

6-
(function($) {
75

8-
module("tooltip: core");
96

10-
11-
})(jQuery);
7+
}( jQuery ) );

tests/unit/tooltip/tooltip_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ commonWidgetTests( "tooltip", {
22
defaults: {
33
disabled: false,
44
items: "[title]",
5-
content: $.ui.tooltip.prototype.options.content,
5+
content: function() {},
66
position: {
77
my: "left+15 center",
88
at: "right center"

tests/unit/tooltip/tooltip_events.js

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,48 @@
1-
/*
2-
* tooltip_events.js
3-
*/
4-
(function($) {
1+
(function( $ ) {
52

6-
module("tooltip: events");
3+
module( "tooltip: events" );
74

8-
test("programmatic triggers", function() {
9-
expect(2);
10-
var e = $("#tooltipped1").tooltip({
11-
open: function(event, ui) {
5+
test( "programmatic triggers", function() {
6+
expect( 2 );
7+
var element = $( "#tooltipped1" ).tooltip({
8+
open: function( event, ui ) {
129
same( event.type, "tooltipopen" );
1310
},
14-
close: function(event, ui) {
11+
close: function( event, ui ) {
1512
same( event.type, "tooltipclose" );
1613
}
1714
});
18-
e.tooltip("open").tooltip("close");
19-
e.tooltip("destroy");
15+
element.tooltip( "open" ).tooltip( "close" );
2016
});
2117

22-
test("mouse events", function() {
23-
expect(4);
24-
var e = $("#tooltipped1").tooltip({
25-
open: function(event, ui) {
18+
test( "mouse events", function() {
19+
expect( 4 );
20+
var element = $( "#tooltipped1" ).tooltip({
21+
open: function( event, ui ) {
2622
same( event.type, "tooltipopen" );
2723
same( event.originalEvent.type, "mouseover" );
2824
},
29-
close: function(event, ui) {
25+
close: function( event, ui ) {
3026
same( event.type, "tooltipclose" );
3127
same( event.originalEvent.type, "mouseleave" );
3228
}
3329
});
34-
e.trigger("mouseover").trigger("mouseleave");
35-
e.tooltip("destroy");
30+
element.trigger( "mouseover" ).trigger( "mouseleave" );
3631
});
3732

38-
test("focus events", function() {
39-
expect(4);
40-
var e = $("#tooltipped1").tooltip({
41-
open: function(event, ui) {
33+
test( "focus events", function() {
34+
expect( 4 );
35+
var element = $( "#tooltipped1" ).tooltip({
36+
open: function( event, ui ) {
4237
same( event.type, "tooltipopen" );
4338
same( event.originalEvent.type, "focusin" );
4439
},
45-
close: function(event, ui) {
40+
close: function( event, ui ) {
4641
same( event.type, "tooltipclose" );
4742
same( event.originalEvent.type, "blur" );
4843
}
4944
});
50-
e.trigger("focus").trigger("blur");
51-
e.tooltip("destroy");
45+
element.trigger( "focus" ).trigger( "blur" );
5246
});
5347

54-
})(jQuery);
48+
}( jQuery ) );

tests/unit/tooltip/tooltip_methods.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
/*
2-
* tooltip_methods.js
3-
*/
4-
(function($) {
5-
1+
(function( $ ) {
62

7-
module("tooltip: methods");
3+
module( "tooltip: methods" );
84

9-
test("destroy", function() {
10-
var beforeHtml = $("#tooltipped1").parent().html();
11-
var afterHtml = $("#tooltipped1").tooltip().tooltip("destroy").parent().html();
5+
test( "destroy", function() {
6+
var beforeHtml = $( "#tooltipped1" ).parent().html();
7+
var afterHtml = $( "#tooltipped1" ).tooltip().tooltip( "destroy" ).parent().html();
128
equal( afterHtml, beforeHtml );
139
});
1410

15-
test("open", function() {
16-
var e = $("#tooltipped1").tooltip();
17-
e.tooltip("open");
18-
ok( $(".ui-tooltip").is(":visible") );
19-
$(":ui-tooltip").tooltip("destroy");
11+
test( "open", function() {
12+
var element = $( "#tooltipped1" ).tooltip();
13+
element.tooltip( "open" );
14+
ok( $( ".ui-tooltip" ).is( ":visible" ) );
2015
});
2116

2217
/*
@@ -29,5 +24,4 @@ test("widget", function() {
2924
});
3025
*/
3126

32-
33-
})(jQuery);
27+
}( jQuery ) );

tests/unit/tooltip/tooltip_options.js

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,41 @@
1-
/*
2-
* tooltip_options.js
3-
*/
4-
(function($) {
5-
6-
module("tooltip: options", {
7-
teardown: function() {
8-
$(":ui-tooltip").tooltip("destroy");
9-
}
10-
});
1+
(function( $ ) {
112

3+
module( "tooltip: options" );
124

13-
test("option: items", function() {
14-
var event = $.Event("mouseenter");
15-
event.target = $("[data-tooltip]");
16-
$("#qunit-fixture").tooltip({
5+
test( "items", function() {
6+
var event = $.Event( "mouseenter" );
7+
event.target = $( "[data-tooltip]" )[ 0 ];
8+
var element = $( "#qunit-fixture" ).tooltip({
179
items: "[data-tooltip]",
1810
content: function() {
19-
return $(this).attr("data-tooltip");
11+
return $( this ).attr( "data-tooltip" );
2012
}
21-
}).tooltip("open", event);
22-
same( $( "#" + $("#fixture-span").attr("aria-describedby") ).text(), "text" );
13+
}).tooltip( "open", event );
14+
same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "text" );
15+
element.tooltip( "destroy" );
2316
});
2417

25-
test("content: default", function() {
26-
$("#tooltipped1").tooltip().tooltip("open");
27-
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "anchortitle" );
18+
test( "content: default", function() {
19+
var element = $( "#tooltipped1" ).tooltip().tooltip("open");
20+
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
2821
});
2922

30-
test("content: return string", function() {
31-
$("#tooltipped1").tooltip({
23+
test( "content: return string", function() {
24+
var element = $( "#tooltipped1" ).tooltip({
3225
content: function() {
3326
return "customstring";
3427
}
35-
}).tooltip("open");
36-
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" );
28+
}).tooltip( "open" );
29+
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
3730
});
3831

39-
test("content: return jQuery", function() {
40-
$("#tooltipped1").tooltip({
32+
test( "content: return jQuery", function() {
33+
var element = $( "#tooltipped1" ).tooltip({
4134
content: function() {
42-
return $("<div></div>").html("cu<b>s</b>tomstring");
35+
return $( "<div>" ).html( "cu<b>s</b>tomstring" );
4336
}
44-
}).tooltip("open");
45-
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" );
37+
}).tooltip( "open" );
38+
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
4639
});
4740

4841
/*
@@ -63,4 +56,4 @@ test("content: callback string", function() {
6356
});
6457
*/
6558

66-
})(jQuery);
59+
}( jQuery ) );

0 commit comments

Comments
 (0)