Skip to content

Commit 9dc2bf9

Browse files
committed
Tests: Fix tooltip tests by destroying tooltips
Some tests were not properly destroying tooltips which made tests start to fail with the new QUnit. Ref jquerygh-2157
1 parent 0977ea1 commit 9dc2bf9

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

tests/unit/tooltip/core.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ QUnit.test( "markup structure", function( assert ) {
2626
assert.equal( tooltip.length, 1, ".ui-tooltip exists" );
2727
assert.equal( tooltip.find( ".ui-tooltip-content" ).length, 1,
2828
".ui-tooltip-content exists" );
29+
30+
element.tooltip( "destroy" );
2931
} );
3032

3133
QUnit.test( "accessibility", function( assert ) {
@@ -95,6 +97,8 @@ QUnit.test( "nested tooltips", function( assert ) {
9597

9698
child.trigger( "mouseover" );
9799
assert.equal( $( ".ui-tooltip" ).text(), "child" );
100+
101+
parent.tooltip( "destroy" );
98102
} );
99103

100104
// #8742
@@ -148,6 +152,7 @@ QUnit.test( "programmatic focus with async content", function( assert ) {
148152

149153
element.on( "tooltipclose", function( event ) {
150154
assert.deepEqual( event.originalEvent.type, "focusout" );
155+
element.tooltip( "destroy" );
151156
ready();
152157
} );
153158

@@ -249,6 +254,7 @@ QUnit.test( "remove conflicting attributes from live region", function( assert )
249254
"no name attributes within live region" );
250255
assert.equal( $( ".ui-helper-hidden-accessible [id]" ).length, 0,
251256
"no id attributes within live region" );
257+
$( "#tooltipped1" ).tooltip( "destroy" );
252258
}
253259
} )
254260
.tooltip( "open" );

tests/unit/tooltip/deprecated.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ QUnit.test( "tooltipClass", function( assert ) {
1616
tooltipClass: "custom"
1717
} ).tooltip( "open" );
1818
assert.hasClasses( $( "#" + element.data( "ui-tooltip-id" ) ), "custom" );
19+
20+
element.tooltip( "destroy" );
1921
} );
2022

2123
} );

tests/unit/tooltip/events.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ QUnit.test( "programmatic triggers", function( assert ) {
2828
assert.strictEqual( ui.tooltip[ 0 ], tooltip[ 0 ], "ui.tooltip" );
2929
} );
3030
element.tooltip( "close" );
31+
element.tooltip( "destroy" );
3132
} );
3233

3334
QUnit.test( "mouse events", function( assert ) {
@@ -44,6 +45,7 @@ QUnit.test( "mouse events", function( assert ) {
4445
} );
4546
element.trigger( "focusout" );
4647
element.trigger( "mouseleave" );
48+
element.tooltip( "destroy" );
4749
} );
4850

4951
QUnit.test( "focus events", function( assert ) {
@@ -60,6 +62,7 @@ QUnit.test( "focus events", function( assert ) {
6062
} );
6163
element.trigger( "mouseleave" );
6264
element.trigger( "focusout" );
65+
element.tooltip( "destroy" );
6366
} );
6467

6568
} );

tests/unit/tooltip/methods.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ QUnit.test( "enable/disable", function( assert ) {
9696
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
9797
assert.ok( tooltip.is( ":visible" ) );
9898
$.fx.off = false;
99+
100+
element.tooltip( "destroy" );
99101
} );
100102

101103
QUnit.test( "enable/disable delegated", function( assert ) {
@@ -118,6 +120,8 @@ QUnit.test( "widget", function( assert ) {
118120
widgetElement = element.tooltip( "widget" );
119121
assert.equal( widgetElement.length, 1, "one element" );
120122
assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
123+
124+
element.tooltip( "destroy" );
121125
} );
122126

123127
QUnit.test( "preserve changes to title attributes on close and destroy", function( assert ) {

tests/unit/tooltip/options.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ QUnit.module( "tooltip: options", beforeAfterEach() );
1212

1313
QUnit.test( "disabled: true", function( assert ) {
1414
assert.expect( 1 );
15-
$( "#tooltipped1" ).tooltip( {
15+
var element = $( "#tooltipped1" ).tooltip( {
1616
disabled: true
1717
} ).tooltip( "open" );
1818
assert.equal( $( ".ui-tooltip" ).length, 0 );
19+
element.tooltip( "destroy" );
1920
} );
2021

2122
QUnit.test( "content: default", function( assert ) {
2223
assert.expect( 1 );
2324
var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
2425
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "anchortitle" );
26+
element.tooltip( "destroy" );
2527
} );
2628

2729
QUnit.test( "content: default; HTML escaping", function( assert ) {
@@ -36,6 +38,7 @@ QUnit.test( "content: default; HTML escaping", function( assert ) {
3638
assert.equal( $.ui.tooltip.hacked, false, "script did not execute" );
3739
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), scriptText,
3840
"correct tooltip text" );
41+
element.tooltip( "destroy" );
3942
} );
4043

4144
QUnit.test( "content: return string", function( assert ) {
@@ -46,6 +49,7 @@ QUnit.test( "content: return string", function( assert ) {
4649
}
4750
} ).tooltip( "open" );
4851
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" );
52+
element.tooltip( "destroy" );
4953
} );
5054

5155
QUnit.test( "content: return jQuery", function( assert ) {
@@ -59,6 +63,7 @@ QUnit.test( "content: return jQuery", function( assert ) {
5963
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" );
6064
assert.equal( liveRegion.children().last().html().toLowerCase(), "<div>cu<b>s</b>tomstring</div>",
6165
"The accessibility live region will strip the ids but keep the structure" );
66+
element.tooltip( "destroy" );
6267
} );
6368

6469
QUnit.test( "content: sync + async callback", function( assert ) {
@@ -72,6 +77,8 @@ QUnit.test( "content: sync + async callback", function( assert ) {
7277
response( "customstring2" );
7378
setTimeout( function() {
7479
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring2" );
80+
81+
element.tooltip( "destroy" );
7582
ready();
7683
}, 13 );
7784
}, 13 );
@@ -94,6 +101,8 @@ QUnit.test( "content: async callback loses focus before load", function( assert
94101
setTimeout( function() {
95102
assert.ok( !$( "#" + element.data( "ui-tooltip-id" ) ).is( ":visible" ),
96103
"Tooltip should not display" );
104+
105+
element.tooltip( "destroy" );
97106
ready();
98107
} );
99108
} );
@@ -117,6 +126,8 @@ QUnit.test( "content: change while open", function( assert ) {
117126
return "new";
118127
} );
119128
assert.equal( ui.tooltip.text(), "new", "updated content" );
129+
130+
element.tooltip( "destroy" );
120131
} );
121132

122133
element.tooltip( "open" );
@@ -129,7 +140,7 @@ QUnit.test( "content: string", function( assert ) {
129140
open: function( event, ui ) {
130141
assert.equal( ui.tooltip.text(), "just a string" );
131142
}
132-
} ).tooltip( "open" );
143+
} ).tooltip( "open" ).tooltip( "destroy" );
133144
} );
134145

135146
QUnit.test( "content: element", function( assert ) {
@@ -141,7 +152,7 @@ QUnit.test( "content: element", function( assert ) {
141152
open: function( event, ui ) {
142153
assert.equal( ui.tooltip.children().html().toLowerCase(), content );
143154
}
144-
} ).tooltip( "open" );
155+
} ).tooltip( "open" ).tooltip( "destroy" );
145156
} );
146157

147158
QUnit.test( "content: jQuery", function( assert ) {
@@ -153,7 +164,7 @@ QUnit.test( "content: jQuery", function( assert ) {
153164
open: function( event, ui ) {
154165
assert.equal( ui.tooltip.children().html().toLowerCase(), content );
155166
}
156-
} ).tooltip( "open" );
167+
} ).tooltip( "open" ).tooltip( "destroy" );
157168
} );
158169

159170
QUnit.test( "items", function( assert ) {
@@ -217,14 +228,17 @@ QUnit.test( "track + show delay", function( assert ) {
217228
topVal + offsetVal, 0.5,
218229
"top position"
219230
);
231+
232+
element.tooltip( "destroy" );
220233
} );
221234

222235
QUnit.test( "track and programmatic focus", function( assert ) {
223236
assert.expect( 1 );
224-
$( "#qunit-fixture div input" ).tooltip( {
237+
var element = $( "#qunit-fixture div input" ).tooltip( {
225238
track: true
226239
} ).trigger( "focus" );
227240
assert.equal( "inputtitle", $( ".ui-tooltip" ).text() );
241+
element.tooltip( "destroy" );
228242
} );
229243

230244
} );

0 commit comments

Comments
 (0)