aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/tooltip
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-03-30 10:09:12 +0200
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-05-10 10:53:57 +0200
commit9dc2bf9737ba9c877b7b9f6e892100580adc0f2e (patch)
tree1bd055234e89af96b82cf0096a7c8a8d98a3ffd4 /tests/unit/tooltip
parent0977ea1b48355bfddc98cb16673ea8b627904dab (diff)
downloadjquery-ui-9dc2bf9737ba9c877b7b9f6e892100580adc0f2e.tar.gz
jquery-ui-9dc2bf9737ba9c877b7b9f6e892100580adc0f2e.zip
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 gh-2157
Diffstat (limited to 'tests/unit/tooltip')
-rw-r--r--tests/unit/tooltip/core.js6
-rw-r--r--tests/unit/tooltip/deprecated.js2
-rw-r--r--tests/unit/tooltip/events.js3
-rw-r--r--tests/unit/tooltip/methods.js4
-rw-r--r--tests/unit/tooltip/options.js24
5 files changed, 34 insertions, 5 deletions
diff --git a/tests/unit/tooltip/core.js b/tests/unit/tooltip/core.js
index a3eedbd6a..0e765c4ba 100644
--- a/tests/unit/tooltip/core.js
+++ b/tests/unit/tooltip/core.js
@@ -26,6 +26,8 @@ QUnit.test( "markup structure", function( assert ) {
assert.equal( tooltip.length, 1, ".ui-tooltip exists" );
assert.equal( tooltip.find( ".ui-tooltip-content" ).length, 1,
".ui-tooltip-content exists" );
+
+ element.tooltip( "destroy" );
} );
QUnit.test( "accessibility", function( assert ) {
@@ -95,6 +97,8 @@ QUnit.test( "nested tooltips", function( assert ) {
child.trigger( "mouseover" );
assert.equal( $( ".ui-tooltip" ).text(), "child" );
+
+ parent.tooltip( "destroy" );
} );
// #8742
@@ -148,6 +152,7 @@ QUnit.test( "programmatic focus with async content", function( assert ) {
element.on( "tooltipclose", function( event ) {
assert.deepEqual( event.originalEvent.type, "focusout" );
+ element.tooltip( "destroy" );
ready();
} );
@@ -249,6 +254,7 @@ QUnit.test( "remove conflicting attributes from live region", function( assert )
"no name attributes within live region" );
assert.equal( $( ".ui-helper-hidden-accessible [id]" ).length, 0,
"no id attributes within live region" );
+ $( "#tooltipped1" ).tooltip( "destroy" );
}
} )
.tooltip( "open" );
diff --git a/tests/unit/tooltip/deprecated.js b/tests/unit/tooltip/deprecated.js
index 4d3975e84..cc4dcf0ee 100644
--- a/tests/unit/tooltip/deprecated.js
+++ b/tests/unit/tooltip/deprecated.js
@@ -16,6 +16,8 @@ QUnit.test( "tooltipClass", function( assert ) {
tooltipClass: "custom"
} ).tooltip( "open" );
assert.hasClasses( $( "#" + element.data( "ui-tooltip-id" ) ), "custom" );
+
+ element.tooltip( "destroy" );
} );
} );
diff --git a/tests/unit/tooltip/events.js b/tests/unit/tooltip/events.js
index 16d1e08cb..f62683b95 100644
--- a/tests/unit/tooltip/events.js
+++ b/tests/unit/tooltip/events.js
@@ -28,6 +28,7 @@ QUnit.test( "programmatic triggers", function( assert ) {
assert.strictEqual( ui.tooltip[ 0 ], tooltip[ 0 ], "ui.tooltip" );
} );
element.tooltip( "close" );
+ element.tooltip( "destroy" );
} );
QUnit.test( "mouse events", function( assert ) {
@@ -44,6 +45,7 @@ QUnit.test( "mouse events", function( assert ) {
} );
element.trigger( "focusout" );
element.trigger( "mouseleave" );
+ element.tooltip( "destroy" );
} );
QUnit.test( "focus events", function( assert ) {
@@ -60,6 +62,7 @@ QUnit.test( "focus events", function( assert ) {
} );
element.trigger( "mouseleave" );
element.trigger( "focusout" );
+ element.tooltip( "destroy" );
} );
} );
diff --git a/tests/unit/tooltip/methods.js b/tests/unit/tooltip/methods.js
index b7a512ad1..5045a622c 100644
--- a/tests/unit/tooltip/methods.js
+++ b/tests/unit/tooltip/methods.js
@@ -96,6 +96,8 @@ QUnit.test( "enable/disable", function( assert ) {
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
assert.ok( tooltip.is( ":visible" ) );
$.fx.off = false;
+
+ element.tooltip( "destroy" );
} );
QUnit.test( "enable/disable delegated", function( assert ) {
@@ -118,6 +120,8 @@ QUnit.test( "widget", function( assert ) {
widgetElement = element.tooltip( "widget" );
assert.equal( widgetElement.length, 1, "one element" );
assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
+
+ element.tooltip( "destroy" );
} );
QUnit.test( "preserve changes to title attributes on close and destroy", function( assert ) {
diff --git a/tests/unit/tooltip/options.js b/tests/unit/tooltip/options.js
index 72a3cf889..f2fbe982a 100644
--- a/tests/unit/tooltip/options.js
+++ b/tests/unit/tooltip/options.js
@@ -12,16 +12,18 @@ QUnit.module( "tooltip: options", beforeAfterEach() );
QUnit.test( "disabled: true", function( assert ) {
assert.expect( 1 );
- $( "#tooltipped1" ).tooltip( {
+ var element = $( "#tooltipped1" ).tooltip( {
disabled: true
} ).tooltip( "open" );
assert.equal( $( ".ui-tooltip" ).length, 0 );
+ element.tooltip( "destroy" );
} );
QUnit.test( "content: default", function( assert ) {
assert.expect( 1 );
var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "anchortitle" );
+ element.tooltip( "destroy" );
} );
QUnit.test( "content: default; HTML escaping", function( assert ) {
@@ -36,6 +38,7 @@ QUnit.test( "content: default; HTML escaping", function( assert ) {
assert.equal( $.ui.tooltip.hacked, false, "script did not execute" );
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), scriptText,
"correct tooltip text" );
+ element.tooltip( "destroy" );
} );
QUnit.test( "content: return string", function( assert ) {
@@ -46,6 +49,7 @@ QUnit.test( "content: return string", function( assert ) {
}
} ).tooltip( "open" );
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" );
+ element.tooltip( "destroy" );
} );
QUnit.test( "content: return jQuery", function( assert ) {
@@ -59,6 +63,7 @@ QUnit.test( "content: return jQuery", function( assert ) {
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" );
assert.equal( liveRegion.children().last().html().toLowerCase(), "<div>cu<b>s</b>tomstring</div>",
"The accessibility live region will strip the ids but keep the structure" );
+ element.tooltip( "destroy" );
} );
QUnit.test( "content: sync + async callback", function( assert ) {
@@ -72,6 +77,8 @@ QUnit.test( "content: sync + async callback", function( assert ) {
response( "customstring2" );
setTimeout( function() {
assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring2" );
+
+ element.tooltip( "destroy" );
ready();
}, 13 );
}, 13 );
@@ -94,6 +101,8 @@ QUnit.test( "content: async callback loses focus before load", function( assert
setTimeout( function() {
assert.ok( !$( "#" + element.data( "ui-tooltip-id" ) ).is( ":visible" ),
"Tooltip should not display" );
+
+ element.tooltip( "destroy" );
ready();
} );
} );
@@ -117,6 +126,8 @@ QUnit.test( "content: change while open", function( assert ) {
return "new";
} );
assert.equal( ui.tooltip.text(), "new", "updated content" );
+
+ element.tooltip( "destroy" );
} );
element.tooltip( "open" );
@@ -129,7 +140,7 @@ QUnit.test( "content: string", function( assert ) {
open: function( event, ui ) {
assert.equal( ui.tooltip.text(), "just a string" );
}
- } ).tooltip( "open" );
+ } ).tooltip( "open" ).tooltip( "destroy" );
} );
QUnit.test( "content: element", function( assert ) {
@@ -141,7 +152,7 @@ QUnit.test( "content: element", function( assert ) {
open: function( event, ui ) {
assert.equal( ui.tooltip.children().html().toLowerCase(), content );
}
- } ).tooltip( "open" );
+ } ).tooltip( "open" ).tooltip( "destroy" );
} );
QUnit.test( "content: jQuery", function( assert ) {
@@ -153,7 +164,7 @@ QUnit.test( "content: jQuery", function( assert ) {
open: function( event, ui ) {
assert.equal( ui.tooltip.children().html().toLowerCase(), content );
}
- } ).tooltip( "open" );
+ } ).tooltip( "open" ).tooltip( "destroy" );
} );
QUnit.test( "items", function( assert ) {
@@ -217,14 +228,17 @@ QUnit.test( "track + show delay", function( assert ) {
topVal + offsetVal, 0.5,
"top position"
);
+
+ element.tooltip( "destroy" );
} );
QUnit.test( "track and programmatic focus", function( assert ) {
assert.expect( 1 );
- $( "#qunit-fixture div input" ).tooltip( {
+ var element = $( "#qunit-fixture div input" ).tooltip( {
track: true
} ).trigger( "focus" );
assert.equal( "inputtitle", $( ".ui-tooltip" ).text() );
+ element.tooltip( "destroy" );
} );
} );