summaryrefslogtreecommitdiff
path: root/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip')
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/all.html30
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip.html51
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_core.js26
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_defaults.js20
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_events.js83
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_methods.js67
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_options.js73
7 files changed, 350 insertions, 0 deletions
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/all.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/all.html
new file mode 100644
index 0000000..0ef6e09
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/all.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Tooltip Test Suite</title>
+
+ <script src="../../../jquery-1.7.1.js"></script>
+
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <link rel="stylesheet" href="../subsuiteRunner.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../subsuiteRunner.js"></script>
+ <script src="../subsuite.js"></script>
+
+ <script>
+ testAllVersions( "tooltip" );
+ </script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Tooltip Test Suite</h1>
+<h2 id="qunit-banner"></h2>
+<div id="qunit-testrunner-toolbar"></div>
+<h2 id="qunit-userAgent"></h2>
+<ol id="qunit-tests"></ol>
+<div id="qunit-fixture">
+
+</div>
+</body>
+</html>
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip.html
new file mode 100644
index 0000000..b5e8558
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip.html
@@ -0,0 +1,51 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Tooltip Test Suite</title>
+
+ <script src="../../jquery.js"></script>
+ <script src="../../resource_loader.js"></script>
+ <script>
+ loadResources({
+ css: [ "ui.core", "ui.tooltip" ],
+ js: [
+ "ui/jquery.ui.core.js",
+ "ui/jquery.ui.widget.js",
+ "ui/jquery.ui.position.js",
+ "ui/jquery.ui.tooltip.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 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>
+
+<h1 id="qunit-header">jQuery UI Tooltip Test Suite</h1>
+<h2 id="qunit-banner"></h2>
+<div id="qunit-testrunner-toolbar"></div>
+<h2 id="qunit-userAgent"></h2>
+<ol id="qunit-tests"></ol>
+<div id="qunit-fixture">
+
+<div>
+ <a id="tooltipped1" href="#" title="anchortitle">anchor</a>
+ <input title="inputtitle">
+ <span id="fixture-span" title="title-text">span</span>
+</div>
+
+</div>
+</body>
+</html>
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_core.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_core.js
new file mode 100644
index 0000000..d18b853
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_core.js
@@ -0,0 +1,26 @@
+(function( $ ) {
+
+module( "tooltip: core" );
+
+test( "markup structure", function() {
+ expect( 6 );
+ 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" );
+
+ element.tooltip( "open" );
+ tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ equal( tooltip.length, 1, "tooltip exists" );
+ ok( tooltip.hasClass( "ui-tooltip" ), "tooltip is .ui-tooltip" );
+ equal( tooltip.length, 1, ".ui-tooltip exists" );
+ equal( tooltip.find( ".ui-tooltip-content" ).length, 1,
+ ".ui-tooltip-content exists" );
+});
+
+test( "accessibility", function() {
+ // TODO: add tests
+});
+
+}( jQuery ) );
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_defaults.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_defaults.js
new file mode 100644
index 0000000..b8b41bf
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_defaults.js
@@ -0,0 +1,20 @@
+commonWidgetTests( "tooltip", {
+ defaults: {
+ content: function() {},
+ disabled: false,
+ hide: true,
+ items: "[title]",
+ position: {
+ my: "left+15 center",
+ at: "right center",
+ collision: "flipfit flipfit"
+ },
+ show: true,
+ tooltipClass: null,
+
+ // callbacks
+ close: null,
+ create: null,
+ open: null
+ }
+});
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_events.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_events.js
new file mode 100644
index 0000000..99e1fbd
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_events.js
@@ -0,0 +1,83 @@
+(function( $ ) {
+
+module( "tooltip: events" );
+
+test( "programmatic triggers", function() {
+ 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],
+ $( "#" + element.attr( "aria-describedby" ) )[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" );
+ });
+ element.tooltip( "close" );
+});
+
+test( "mouse events", function() {
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event ) {
+ same( event.originalEvent.type, "mouseover" );
+ });
+ element.trigger( "mouseover" );
+
+ element.one( "tooltipclose", function( event ) {
+ same( event.originalEvent.type, "mouseleave" );
+ });
+ element.trigger( "mouseleave" );
+});
+
+test( "focus events", function() {
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event ) {
+ same( event.originalEvent.type, "focusin" );
+ });
+ element.trigger( "focusin" );
+
+ element.one( "tooltipclose", function( event ) {
+ same( event.originalEvent.type, "blur" );
+ });
+ element.trigger( "blur" );
+});
+
+asyncTest( "mixed events", function() {
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event ) {
+ same( event.originalEvent.type, "focusin" );
+ });
+ element.simulate( "focus" );
+
+ element.one( "tooltipopen", function() {
+ ok( false, "open triggered while already open" );
+ });
+ element.trigger( "mouseover" );
+
+ element.bind( "tooltipclose", function( event ) {
+ ok( false, "close triggered while still focused" );
+ });
+ element.trigger( "mouseleave" );
+ element.unbind( "tooltipclose" );
+
+ // blurring is async in IE
+ element.one( "tooltipclose", function( event ) {
+ same( event.originalEvent.type, "blur" );
+ start();
+ });
+ element.simulate( "blur" );
+});
+
+}( jQuery ) );
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_methods.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_methods.js
new file mode 100644
index 0000000..74fd35d
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_methods.js
@@ -0,0 +1,67 @@
+(function( $ ) {
+
+module( "tooltip: methods" );
+
+test( "destroy", function() {
+ expect( 2 );
+ domEqual( "#tooltipped1", function() {
+ $( "#tooltipped1" ).tooltip().tooltip( "destroy" );
+ });
+
+ // make sure that open tooltips are removed on destroy
+ $( "#tooltipped1" ).tooltip().tooltip( "open" ).tooltip( "destroy" );
+ equal( $( ".ui-tooltip" ).length, 0 );
+});
+
+test( "open/close", function() {
+ expect( 3 );
+ $.fx.off = true;
+ var element = $( "#tooltipped1" ).tooltip();
+ equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
+
+ element.tooltip( "open" );
+ var tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ ok( tooltip.is( ":visible" ) );
+
+ element.tooltip( "close" );
+ ok( tooltip.is( ":hidden" ) );
+ $.fx.off = false;
+});
+
+test( "enable/disable", function() {
+ expect( 7 );
+ $.fx.off = true;
+ var element = $( "#tooltipped1" ).tooltip();
+ equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
+
+ element.tooltip( "open" );
+ var tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ ok( tooltip.is( ":visible" ) );
+
+ element.tooltip( "disable" );
+ equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" );
+ equal( tooltip.attr( "title" ), undefined, "title removed on disable" );
+
+ element.tooltip( "open" );
+ equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" );
+
+ element.tooltip( "enable" );
+ equal( element.attr( "title" ), "anchortitle", "title restored on enable" );
+
+ element.tooltip( "open" );
+ tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ ok( tooltip.is( ":visible" ) );
+ $.fx.off = false;
+});
+
+/*
+TODO currently tooltip doesn't override widget
+can't return anything useful if no element is kept around and there's no useful reference
+test("widget", function() {
+ var tooltip = $("#tooltipped1").tooltip();
+ same(tooltip.tooltip("widget")[0], $(".ui-tooltip")[0]);
+ same(tooltip.tooltip("widget").end()[0], tooltip[0]);
+});
+*/
+
+}( jQuery ) );
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_options.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_options.js
new file mode 100644
index 0000000..04bb4c6
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_options.js
@@ -0,0 +1,73 @@
+(function( $ ) {
+
+module( "tooltip: options" );
+
+test( "content: default", function() {
+ var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
+ same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
+});
+
+test( "content: return string", function() {
+ var element = $( "#tooltipped1" ).tooltip({
+ content: function() {
+ return "customstring";
+ }
+ }).tooltip( "open" );
+ same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
+});
+
+test( "content: return jQuery", function() {
+ var element = $( "#tooltipped1" ).tooltip({
+ content: function() {
+ return $( "<div>" ).html( "cu<b>s</b>tomstring" );
+ }
+ }).tooltip( "open" );
+ same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
+});
+
+asyncTest( "content: sync + async callback", function() {
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip({
+ content: function( response ) {
+ setTimeout(function() {
+ same( $( "#" + element.attr("aria-describedby") ).text(), "loading..." );
+
+ response( "customstring2" );
+ setTimeout(function() {
+ same( $( "#" + element.attr("aria-describedby") ).text(), "customstring2" );
+ start();
+ }, 13 );
+ }, 13 );
+ return "loading...";
+ }
+ }).tooltip( "open" );
+});
+
+test( "items", function() {
+ expect( 2 );
+ var element = $( "#qunit-fixture" ).tooltip({
+ items: "#fixture-span"
+ });
+
+ var event = $.Event( "mouseenter" );
+ event.target = $( "#fixture-span" )[ 0 ];
+ element.tooltip( "open", event );
+ same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
+
+ // make sure default [title] doesn't get used
+ event.target = $( "#tooltipped1" )[ 0 ];
+ element.tooltip( "open", event );
+ same( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined );
+
+ element.tooltip( "destroy" );
+});
+
+test( "tooltipClass", function() {
+ expect( 1 )
+ var element = $( "#tooltipped1" ).tooltip({
+ tooltipClass: "custom"
+ }).tooltip( "open" );
+ ok( $( "#" + element.attr( "aria-describedby" ) ).hasClass( "custom" ) );
+});
+
+}( jQuery ) );