From 3909e6d89e01e4cd8777377c63037896bb95aa2f Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Fri, 25 Nov 2011 21:18:19 +0100 Subject: new jq layout --- .../jquery-ui-1.9pre/tests/unit/tooltip/all.html | 30 ++++++++ .../tests/unit/tooltip/tooltip.html | 51 +++++++++++++ .../tests/unit/tooltip/tooltip_core.js | 26 +++++++ .../tests/unit/tooltip/tooltip_defaults.js | 20 ++++++ .../tests/unit/tooltip/tooltip_events.js | 83 ++++++++++++++++++++++ .../tests/unit/tooltip/tooltip_methods.js | 67 +++++++++++++++++ .../tests/unit/tooltip/tooltip_options.js | 73 +++++++++++++++++++ 7 files changed, 350 insertions(+) create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/all.html create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip.html create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_core.js create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_defaults.js create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_events.js create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_methods.js create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip/tooltip_options.js (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/tooltip') 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 @@ + + + + + jQuery UI Tooltip Test Suite + + + + + + + + + + + + + +

jQuery UI Tooltip Test Suite

+

+
+

+
    +
    + +
    + + 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 @@ + + + + + jQuery UI Tooltip Test Suite + + + + + + + + + + + + + + + + + + + + +

    jQuery UI Tooltip Test Suite

    +

    +
    +

    +
      +
      + +
      + anchor + + span +
      + +
      + + 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 $( "
      " ).html( "customstring" ); + } + }).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 ) ); -- cgit v1.1