From: Amanpreet Singh Date: Wed, 6 Apr 2016 13:59:12 +0000 (+0530) Subject: Tooltip: Shift to use no globals X-Git-Tag: 1.12.0-rc.2~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=92f122d5b1c1eaa77ae0ab3af8bf68bf268e300d;p=jquery-ui.git Tooltip: Shift to use no globals --- diff --git a/tests/unit/tooltip/core.js b/tests/unit/tooltip/core.js index 0dfdc5825..2de37097a 100644 --- a/tests/unit/tooltip/core.js +++ b/tests/unit/tooltip/core.js @@ -1,83 +1,84 @@ define( [ + "qunit", "jquery", "ui/widgets/tooltip" -], function( $ ) { +], function( QUnit, $ ) { -module( "tooltip: core" ); +QUnit.module( "tooltip: core" ); -test( "markup structure", function( assert ) { - expect( 7 ); +QUnit.test( "markup structure", function( assert ) { + assert.expect( 7 ); var element = $( "#tooltipped1" ).tooltip(), tooltip = $( ".ui-tooltip" ); - equal( element.attr( "aria-describedby" ), undefined, "no aria-describedby on init" ); - equal( tooltip.length, 0, "no tooltip on init" ); + assert.equal( element.attr( "aria-describedby" ), undefined, "no aria-describedby on init" ); + assert.equal( tooltip.length, 0, "no tooltip on init" ); element.tooltip( "open" ); tooltip = $( "#" + element.data( "ui-tooltip-id" ) ); - equal( tooltip.length, 1, "tooltip exists" ); - equal( element.attr( "aria-describedby" ), tooltip.attr( "id" ), "aria-describedby" ); + assert.equal( tooltip.length, 1, "tooltip exists" ); + assert.equal( element.attr( "aria-describedby" ), tooltip.attr( "id" ), "aria-describedby" ); assert.hasClasses( tooltip, "ui-tooltip ui-widget ui-widget-content ui-widget-shadow" ); - equal( tooltip.length, 1, ".ui-tooltip exists" ); - equal( tooltip.find( ".ui-tooltip-content" ).length, 1, + assert.equal( tooltip.length, 1, ".ui-tooltip exists" ); + assert.equal( tooltip.find( ".ui-tooltip-content" ).length, 1, ".ui-tooltip-content exists" ); } ); -test( "accessibility", function() { - expect( 15 ); +QUnit.test( "accessibility", function( assert ) { + assert.expect( 15 ); var tooltipId, tooltip, element = $( "#multiple-describedby" ).tooltip(), liveRegion = element.tooltip( "instance" ).liveRegion; - equal( liveRegion.find( ">div" ).length, 0 ); - equal( liveRegion.attr( "role" ), "log" ); - equal( liveRegion.attr( "aria-live" ), "assertive" ); - equal( liveRegion.attr( "aria-relevant" ), "additions" ); + assert.equal( liveRegion.find( ">div" ).length, 0 ); + assert.equal( liveRegion.attr( "role" ), "log" ); + assert.equal( liveRegion.attr( "aria-live" ), "assertive" ); + assert.equal( liveRegion.attr( "aria-relevant" ), "additions" ); element.tooltip( "open" ); tooltipId = element.data( "ui-tooltip-id" ); tooltip = $( "#" + tooltipId ); - equal( tooltip.attr( "role" ), "tooltip", "role" ); - equal( element.attr( "aria-describedby" ), "fixture-span " + tooltipId, + assert.equal( tooltip.attr( "role" ), "tooltip", "role" ); + assert.equal( element.attr( "aria-describedby" ), "fixture-span " + tooltipId, "multiple describedby when open" ); - equal( element.attr( "title" ), null, "no title when open" ); - equal( liveRegion.children().length, 1 ); - equal( liveRegion.children().last().html(), "..." ); + assert.equal( element.attr( "title" ), null, "no title when open" ); + assert.equal( liveRegion.children().length, 1 ); + assert.equal( liveRegion.children().last().html(), "..." ); element.tooltip( "close" ); - equal( element.attr( "aria-describedby" ), "fixture-span", + assert.equal( element.attr( "aria-describedby" ), "fixture-span", "correct describedby when closed" ); - equal( element.attr( "title" ), "...", "title restored when closed" ); + assert.equal( element.attr( "title" ), "...", "title restored when closed" ); element.tooltip( "open" ); - equal( liveRegion.children().length, 2, + assert.equal( liveRegion.children().length, 2, "After the second tooltip show, there should be two children" ); - equal( liveRegion.children().filter( ":visible" ).length, 1, + assert.equal( liveRegion.children().filter( ":visible" ).length, 1, "Only one of the children should be visible" ); - ok( liveRegion.children().last().is( ":visible" ), + assert.ok( liveRegion.children().last().is( ":visible" ), "Only the last child should be visible" ); element.tooltip( "close" ); element.tooltip( "destroy" ); - equal( liveRegion.parent().length, 0, + assert.equal( liveRegion.parent().length, 0, "Tooltip liveregion element should be removed" ); } ); -test( "delegated removal", function() { - expect( 2 ); +QUnit.test( "delegated removal", function( assert ) { + assert.expect( 2 ); var container = $( "#contains-tooltipped" ).tooltip(), element = $( "#contained-tooltipped" ); element.trigger( "mouseover" ); - equal( $( ".ui-tooltip" ).length, 1 ); + assert.equal( $( ".ui-tooltip" ).length, 1 ); container.empty(); - equal( $( ".ui-tooltip" ).length, 0 ); + assert.equal( $( ".ui-tooltip" ).length, 0 ); } ); -test( "nested tooltips", function() { - expect( 2 ); +QUnit.test( "nested tooltips", function( assert ) { + assert.expect( 2 ); var child = $( "#contained-tooltipped" ), parent = $( "#contains-tooltipped" ).tooltip( { @@ -86,15 +87,15 @@ test( "nested tooltips", function() { } ); parent.trigger( "mouseover" ); - equal( $( ".ui-tooltip:visible" ).text(), "parent" ); + assert.equal( $( ".ui-tooltip:visible" ).text(), "parent" ); child.trigger( "mouseover" ); - equal( $( ".ui-tooltip" ).text(), "child" ); + assert.equal( $( ".ui-tooltip" ).text(), "child" ); } ); // #8742 -test( "form containing an input with name title", function() { - expect( 4 ); +QUnit.test( "form containing an input with name title", function( assert ) { + assert.expect( 4 ); var form = $( "#tooltip-form" ).tooltip( { show: null, @@ -102,33 +103,34 @@ test( "form containing an input with name title", function() { } ), input = form.find( "[name=title]" ); - equal( $( ".ui-tooltip" ).length, 0, "no tooltips on init" ); + assert.equal( $( ".ui-tooltip" ).length, 0, "no tooltips on init" ); input.trigger( "mouseover" ); - equal( $( ".ui-tooltip" ).length, 1, "tooltip for input" ); + assert.equal( $( ".ui-tooltip" ).length, 1, "tooltip for input" ); input.trigger( "mouseleave" ); - equal( $( ".ui-tooltip" ).length, 0, "tooltip for input closed" ); + assert.equal( $( ".ui-tooltip" ).length, 0, "tooltip for input closed" ); form.trigger( "mouseover" ); - equal( $( ".ui-tooltip" ).length, 0, "no tooltip for form" ); + assert.equal( $( ".ui-tooltip" ).length, 0, "no tooltip for form" ); } ); -test( "tooltip on .ui-state-disabled element", function() { - expect( 2 ); +QUnit.test( "tooltip on .ui-state-disabled element", function( assert ) { + assert.expect( 2 ); var container = $( "#contains-tooltipped" ).tooltip(), element = $( "#contained-tooltipped" ).addClass( "ui-state-disabled" ); element.trigger( "mouseover" ); - equal( $( ".ui-tooltip" ).length, 1 ); + assert.equal( $( ".ui-tooltip" ).length, 1 ); container.empty(); - equal( $( ".ui-tooltip" ).length, 0 ); + assert.equal( $( ".ui-tooltip" ).length, 0 ); } ); // http://bugs.jqueryui.com/ticket/8740 -asyncTest( "programmatic focus with async content", function() { - expect( 2 ); +QUnit.test( "programmatic focus with async content", function( assert ) { + var ready = assert.async(); + assert.expect( 2 ); var element = $( "#tooltipped1" ).tooltip( { content: function( response ) { setTimeout( function() { @@ -138,11 +140,11 @@ asyncTest( "programmatic focus with async content", function() { } ); element.on( "tooltipopen", function( event ) { - deepEqual( event.originalEvent.type, "focusin" ); + assert.deepEqual( event.originalEvent.type, "focusin" ); element.on( "tooltipclose", function( event ) { - deepEqual( event.originalEvent.type, "focusout" ); - start(); + assert.deepEqual( event.originalEvent.type, "focusout" ); + ready(); } ); setTimeout( function() { @@ -153,8 +155,9 @@ asyncTest( "programmatic focus with async content", function() { element.trigger( "focus" ); } ); -asyncTest( "destroy during hide animation; only one close event", function() { - expect( 1 ); +QUnit.test( "destroy during hide animation; only one close event", function( assert ) { + var ready = assert.async(); + assert.expect( 1 ); var element = $( "#tooltipped1" ).tooltip( { show: false, @@ -162,20 +165,21 @@ asyncTest( "destroy during hide animation; only one close event", function() { } ); element.on( "tooltipclose", function() { - ok( true, "tooltip closed" ); + assert.ok( true, "tooltip closed" ); } ); element.tooltip( "open" ); element.tooltip( "close" ); setTimeout( function() { element.tooltip( "destroy" ); - start(); + ready(); } ); } ); // http://bugs.jqueryui.com/ticket/10602 -asyncTest( "multiple active delegated tooltips", function() { - expect( 1 ); +QUnit.test( "multiple active delegated tooltips", function( assert ) { + var ready = assert.async(); + assert.expect( 1 ); var anchor = $( "#tooltipped1" ), input = anchor.next(), @@ -209,21 +213,21 @@ asyncTest( "multiple active delegated tooltips", function() { function step4() { anchor.simulate( "mouseout" ); - deepEqual( actions, [ + assert.deepEqual( actions, [ "open:anchortitle", "open:inputtitle", "close:inputtitle", "close:anchortitle" ], "Both tooltips open and close" ); - start(); + ready(); } step1(); } ); // http://bugs.jqueryui.com/ticket/11272 -test( "remove conflicting attributes from live region", function() { - expect( 2 ); +QUnit.test( "remove conflicting attributes from live region", function( assert ) { + assert.expect( 2 ); var element = $( "
" + @@ -237,9 +241,9 @@ test( "remove conflicting attributes from live region", function() { .tooltip( { content: element, open: function() { - equal( $( ".ui-helper-hidden-accessible [name]" ).length, 0, + assert.equal( $( ".ui-helper-hidden-accessible [name]" ).length, 0, "no name attributes within live region" ); - equal( $( ".ui-helper-hidden-accessible [id]" ).length, 0, + assert.equal( $( ".ui-helper-hidden-accessible [id]" ).length, 0, "no id attributes within live region" ); } } ) diff --git a/tests/unit/tooltip/deprecated.js b/tests/unit/tooltip/deprecated.js index 7fc7d91a4..bce1a6c6a 100644 --- a/tests/unit/tooltip/deprecated.js +++ b/tests/unit/tooltip/deprecated.js @@ -1,12 +1,13 @@ define( [ + "qunit", "jquery", "ui/widgets/tooltip" -], function( $ ) { +], function( QUnit, $ ) { -module( "tooltip: (deprecated) options" ); +QUnit.module( "tooltip: (deprecated) options" ); -test( "tooltipClass", function( assert ) { - expect( 1 ); +QUnit.test( "tooltipClass", function( assert ) { + assert.expect( 1 ); var element = $( "#tooltipped1" ).tooltip( { tooltipClass: "custom" } ).tooltip( "open" ); diff --git a/tests/unit/tooltip/events.js b/tests/unit/tooltip/events.js index 3cf65fc4e..3fbb683a5 100644 --- a/tests/unit/tooltip/events.js +++ b/tests/unit/tooltip/events.js @@ -1,57 +1,58 @@ define( [ + "qunit", "jquery", "ui/widgets/tooltip" -], function( $ ) { +], function( QUnit, $ ) { -module( "tooltip: events" ); +QUnit.module( "tooltip: events" ); -test( "programmatic triggers", function() { - expect( 4 ); +QUnit.test( "programmatic triggers", function( assert ) { + assert.expect( 4 ); var tooltip, element = $( "#tooltipped1" ).tooltip(); element.one( "tooltipopen", function( event, ui ) { tooltip = ui.tooltip; - ok( !( "originalEvent" in event ), "open" ); - strictEqual( ui.tooltip[ 0 ], + assert.ok( !( "originalEvent" in event ), "open" ); + assert.strictEqual( ui.tooltip[ 0 ], $( "#" + element.data( "ui-tooltip-id" ) )[ 0 ], "ui.tooltip" ); } ); element.tooltip( "open" ); element.one( "tooltipclose", function( event, ui ) { - ok( !( "originalEvent" in event ), "close" ); - strictEqual( ui.tooltip[ 0 ], tooltip[ 0 ], "ui.tooltip" ); + assert.ok( !( "originalEvent" in event ), "close" ); + assert.strictEqual( ui.tooltip[ 0 ], tooltip[ 0 ], "ui.tooltip" ); } ); element.tooltip( "close" ); } ); -test( "mouse events", function() { - expect( 2 ); +QUnit.test( "mouse events", function( assert ) { + assert.expect( 2 ); var element = $( "#tooltipped1" ).tooltip(); element.on( "tooltipopen", function( event ) { - deepEqual( event.originalEvent.type, "mouseover" ); + assert.deepEqual( event.originalEvent.type, "mouseover" ); } ); element.trigger( "mouseover" ); element.on( "tooltipclose", function( event ) { - deepEqual( event.originalEvent.type, "mouseleave" ); + assert.deepEqual( event.originalEvent.type, "mouseleave" ); } ); element.trigger( "focusout" ); element.trigger( "mouseleave" ); } ); -test( "focus events", function() { - expect( 2 ); +QUnit.test( "focus events", function( assert ) { + assert.expect( 2 ); var element = $( "#tooltipped1" ).tooltip(); element.on( "tooltipopen", function( event ) { - deepEqual( event.originalEvent.type, "focusin" ); + assert.deepEqual( event.originalEvent.type, "focusin" ); } ); element.trigger( "focusin" ); element.on( "tooltipclose", function( event ) { - deepEqual( event.originalEvent.type, "focusout" ); + assert.deepEqual( event.originalEvent.type, "focusout" ); } ); element.trigger( "mouseleave" ); element.trigger( "focusout" ); diff --git a/tests/unit/tooltip/methods.js b/tests/unit/tooltip/methods.js index 31fe86532..e98d1b9ed 100644 --- a/tests/unit/tooltip/methods.js +++ b/tests/unit/tooltip/methods.js @@ -1,12 +1,13 @@ define( [ + "qunit", "jquery", "ui/widgets/tooltip" -], function( $ ) { +], function( QUnit, $ ) { -module( "tooltip: methods" ); +QUnit.module( "tooltip: methods" ); -test( "destroy", function( assert ) { - expect( 3 ); +QUnit.test( "destroy", function( assert ) { + assert.expect( 3 ); var element = $( "#tooltipped1" ); assert.domEqual( "#tooltipped1", function() { @@ -20,89 +21,89 @@ test( "destroy", function( assert ) { .tooltip( "open", $.Event( "mouseover", { target: element[ 0 ] } ) ) .tooltip( "destroy" ); } ); - equal( $( ".ui-tooltip" ).length, 0 ); + assert.equal( $( ".ui-tooltip" ).length, 0 ); } ); -test( "open/close", function() { - expect( 3 ); +QUnit.test( "open/close", function( assert ) { + assert.expect( 3 ); $.fx.off = true; var tooltip, element = $( "#tooltipped1" ).tooltip(); - equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" ); + assert.equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" ); element.tooltip( "open" ); tooltip = $( "#" + element.data( "ui-tooltip-id" ) ); - ok( tooltip.is( ":visible" ) ); + assert.ok( tooltip.is( ":visible" ) ); element.tooltip( "close" ); - ok( tooltip.is( ":hidden" ) ); + assert.ok( tooltip.is( ":hidden" ) ); $.fx.off = false; } ); // #8626 - Calling open() without an event -test( "open/close with tracking", function() { - expect( 3 ); +QUnit.test( "open/close with tracking", function( assert ) { + assert.expect( 3 ); $.fx.off = true; var tooltip, element = $( "#tooltipped1" ).tooltip( { track: true } ); - equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" ); + assert.equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" ); element.tooltip( "open" ); tooltip = $( "#" + element.data( "ui-tooltip-id" ) ); - ok( tooltip.is( ":visible" ) ); + assert.ok( tooltip.is( ":visible" ) ); element.tooltip( "close" ); - ok( tooltip.is( ":hidden" ) ); + assert.ok( tooltip.is( ":hidden" ) ); $.fx.off = false; } ); -test( "enable/disable", function( assert ) { - expect( 11 ); +QUnit.test( "enable/disable", function( assert ) { + assert.expect( 11 ); $.fx.off = true; var tooltip, element = $( "#tooltipped1" ).tooltip(); - equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" ); + assert.equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" ); element.tooltip( "open" ); tooltip = $( "#" + element.data( "ui-tooltip-id" ) ); - ok( tooltip.is( ":visible" ) ); + assert.ok( tooltip.is( ":visible" ) ); element.tooltip( "disable" ); - equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" ); + assert.equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" ); assert.lacksClasses( element.tooltip( "widget" ), "ui-state-disabled" ); - ok( !element.tooltip( "widget" ).attr( "aria-disabled" ), "element doesn't get aria-disabled" ); + assert.ok( !element.tooltip( "widget" ).attr( "aria-disabled" ), "element doesn't get aria-disabled" ); assert.lacksClasses( element.tooltip( "widget" ), "ui-tooltip-disabled" ); - equal( tooltip.attr( "title" ), null, "title removed on disable" ); + assert.equal( tooltip.attr( "title" ), null, "title removed on disable" ); element.tooltip( "open" ); - equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" ); + assert.equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" ); element.tooltip( "enable" ); - equal( element.attr( "title" ), "anchortitle", "title restored on enable" ); + assert.equal( element.attr( "title" ), "anchortitle", "title restored on enable" ); // #9719 - Title should be preserved after disabling twice element.tooltip( "disable" ); element.tooltip( "disable" ); element.tooltip( "enable" ); - equal( element.attr( "title" ), "anchortitle", "title restored on enable after being disabled twice" ); + assert.equal( element.attr( "title" ), "anchortitle", "title restored on enable after being disabled twice" ); element.tooltip( "open" ); tooltip = $( "#" + element.data( "ui-tooltip-id" ) ); - ok( tooltip.is( ":visible" ) ); + assert.ok( tooltip.is( ":visible" ) ); $.fx.off = false; } ); -test( "widget", function() { - expect( 2 ); +QUnit.test( "widget", function( assert ) { + assert.expect( 2 ); var element = $( "#tooltipped1" ).tooltip(), widgetElement = element.tooltip( "widget" ); - equal( widgetElement.length, 1, "one element" ); - strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); + assert.equal( widgetElement.length, 1, "one element" ); + assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); } ); -test( "preserve changes to title attributes on close and destroy", function() { - expect( 6 ); +QUnit.test( "preserve changes to title attributes on close and destroy", function( assert ) { + assert.expect( 6 ); var element = $( "#tooltipped1" ), changed = "changed title text", original = "original title text", @@ -136,7 +137,7 @@ test( "preserve changes to title attributes on close and destroy", function() { element.removeAttr( "title" ); } element.tooltip( test.method ); - equal( $( "#tooltipped1" ).attr( "title" ), test.expected ); + assert.equal( $( "#tooltipped1" ).attr( "title" ), test.expected ); } ); } ); diff --git a/tests/unit/tooltip/options.js b/tests/unit/tooltip/options.js index a35d140fb..6dec36a6c 100644 --- a/tests/unit/tooltip/options.js +++ b/tests/unit/tooltip/options.js @@ -1,26 +1,27 @@ define( [ + "qunit", "jquery", "ui/widgets/tooltip" -], function( $ ) { +], function( QUnit, $ ) { -module( "tooltip: options" ); +QUnit.module( "tooltip: options" ); -test( "disabled: true", function() { - expect( 1 ); +QUnit.test( "disabled: true", function( assert ) { + assert.expect( 1 ); $( "#tooltipped1" ).tooltip( { disabled: true } ).tooltip( "open" ); - equal( $( ".ui-tooltip" ).length, 0 ); + assert.equal( $( ".ui-tooltip" ).length, 0 ); } ); -test( "content: default", function() { - expect( 1 ); +QUnit.test( "content: default", function( assert ) { + assert.expect( 1 ); var element = $( "#tooltipped1" ).tooltip().tooltip( "open" ); - deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "anchortitle" ); + assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "anchortitle" ); } ); -test( "content: default; HTML escaping", function() { - expect( 2 ); +QUnit.test( "content: default; HTML escaping", function( assert ) { + assert.expect( 2 ); var scriptText = "", element = $( "#tooltipped1" ); @@ -28,45 +29,46 @@ test( "content: default; HTML escaping", function() { element.attr( "title", scriptText ) .tooltip() .tooltip( "open" ); - equal( $.ui.tooltip.hacked, false, "script did not execute" ); - deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), scriptText, + assert.equal( $.ui.tooltip.hacked, false, "script did not execute" ); + assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), scriptText, "correct tooltip text" ); } ); -test( "content: return string", function() { - expect( 1 ); +QUnit.test( "content: return string", function( assert ) { + assert.expect( 1 ); var element = $( "#tooltipped1" ).tooltip( { content: function() { return "customstring"; } } ).tooltip( "open" ); - deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" ); + assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" ); } ); -test( "content: return jQuery", function() { - expect( 2 ); +QUnit.test( "content: return jQuery", function( assert ) { + assert.expect( 2 ); var element = $( "#tooltipped1" ).tooltip( { content: function() { return $( "
" ).html( "customstring" ); } } ).tooltip( "open" ), liveRegion = element.tooltip( "instance" ).liveRegion; - deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" ); - equal( liveRegion.children().last().html().toLowerCase(), "
customstring
", + assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring" ); + assert.equal( liveRegion.children().last().html().toLowerCase(), "
customstring
", "The accessibility live region will strip the ids but keep the structure" ); } ); -asyncTest( "content: sync + async callback", function() { - expect( 2 ); +QUnit.test( "content: sync + async callback", function( assert ) { + var ready = assert.async(); + assert.expect( 2 ); var element = $( "#tooltipped1" ).tooltip( { content: function( response ) { setTimeout( function() { - deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "loading..." ); + assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "loading..." ); response( "customstring2" ); setTimeout( function() { - deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring2" ); - start(); + assert.deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "customstring2" ); + ready(); }, 13 ); }, 13 ); return "loading..."; @@ -75,8 +77,9 @@ asyncTest( "content: sync + async callback", function() { } ); // http://bugs.jqueryui.com/ticket/8740 -asyncTest( "content: async callback loses focus before load", function() { - expect( 1 ); +QUnit.test( "content: async callback loses focus before load", function( assert ) { + var ready = assert.async(); + assert.expect( 1 ); var element = $( "#tooltipped1" ).tooltip( { content: function( response ) { @@ -85,9 +88,9 @@ asyncTest( "content: async callback loses focus before load", function() { setTimeout( function() { response( "sometext" ); setTimeout( function() { - ok( !$( "#" + element.data( "ui-tooltip-id" ) ).is( ":visible" ), + assert.ok( !$( "#" + element.data( "ui-tooltip-id" ) ).is( ":visible" ), "Tooltip should not display" ); - start(); + ready(); } ); } ); } ); @@ -96,8 +99,8 @@ asyncTest( "content: async callback loses focus before load", function() { element.trigger( "mouseover" ); } ); -test( "content: change while open", function() { - expect( 2 ) ; +QUnit.test( "content: change while open", function( assert ) { + assert.expect( 2 ) ; var element = $( "#tooltipped1" ).tooltip( { content: function() { return "old"; @@ -105,52 +108,52 @@ test( "content: change while open", function() { } ); element.one( "tooltipopen", function( event, ui ) { - equal( ui.tooltip.text(), "old", "original content" ); + assert.equal( ui.tooltip.text(), "old", "original content" ); element.tooltip( "option", "content", function() { return "new"; } ); - equal( ui.tooltip.text(), "new", "updated content" ); + assert.equal( ui.tooltip.text(), "new", "updated content" ); } ); element.tooltip( "open" ); } ); -test( "content: string", function() { - expect( 1 ); +QUnit.test( "content: string", function( assert ) { + assert.expect( 1 ); $( "#tooltipped1" ).tooltip( { content: "just a string", open: function( event, ui ) { - equal( ui.tooltip.text(), "just a string" ); + assert.equal( ui.tooltip.text(), "just a string" ); } } ).tooltip( "open" ); } ); -test( "content: element", function() { - expect( 1 ); +QUnit.test( "content: element", function( assert ) { + assert.expect( 1 ); var content = "

this is a test of the emergency broadcast system.

", element = $( content )[ 0 ]; $( "#tooltipped1" ).tooltip( { content: element, open: function( event, ui ) { - equal( ui.tooltip.children().html().toLowerCase(), content ); + assert.equal( ui.tooltip.children().html().toLowerCase(), content ); } } ).tooltip( "open" ); } ); -test( "content: jQuery", function() { - expect( 1 ); +QUnit.test( "content: jQuery", function( assert ) { + assert.expect( 1 ); var content = "

this is a test of the emergency broadcast system.

", element = $( content ); $( "#tooltipped1" ).tooltip( { content: element, open: function( event, ui ) { - equal( ui.tooltip.children().html().toLowerCase(), content ); + assert.equal( ui.tooltip.children().html().toLowerCase(), content ); } } ).tooltip( "open" ); } ); -test( "items", function() { - expect( 2 ); +QUnit.test( "items", function( assert ) { + assert.expect( 2 ); var event, element = $( "#qunit-fixture" ).tooltip( { items: "#fixture-span" @@ -159,18 +162,18 @@ test( "items", function() { event = $.Event( "mouseenter" ); event.target = $( "#fixture-span" )[ 0 ]; element.tooltip( "open", event ); - deepEqual( $( "#" + $( "#fixture-span" ).data( "ui-tooltip-id" ) ).text(), "title-text" ); + assert.deepEqual( $( "#" + $( "#fixture-span" ).data( "ui-tooltip-id" ) ).text(), "title-text" ); // Make sure default [title] doesn't get used event.target = $( "#tooltipped1" )[ 0 ]; element.tooltip( "open", event ); - deepEqual( $( "#tooltipped1" ).data( "ui-tooltip-id" ), undefined ); + assert.deepEqual( $( "#tooltipped1" ).data( "ui-tooltip-id" ), undefined ); element.tooltip( "destroy" ); } ); -test( "track + show delay", function() { - expect( 2 ); +QUnit.test( "track + show delay", function( assert ) { + assert.expect( 2 ); var event, leftVal = 314, topVal = 159, @@ -200,16 +203,16 @@ test( "track + show delay", function() { event.pageY = topVal; element.trigger( event ); - equal( $( ".ui-tooltip" ).css( "left" ), leftVal + offsetVal + "px" ); - equal( $( ".ui-tooltip" ).css( "top" ), topVal + offsetVal + "px" ); + assert.equal( $( ".ui-tooltip" ).css( "left" ), leftVal + offsetVal + "px" ); + assert.equal( $( ".ui-tooltip" ).css( "top" ), topVal + offsetVal + "px" ); } ); -test( "track and programmatic focus", function() { - expect( 1 ); +QUnit.test( "track and programmatic focus", function( assert ) { + assert.expect( 1 ); $( "#qunit-fixture div input" ).tooltip( { track: true } ).trigger( "focus" ); - equal( "inputtitle", $( ".ui-tooltip" ).text() ); + assert.equal( "inputtitle", $( ".ui-tooltip" ).text() ); } ); } );