/[projects]/misc/horsensspejder-web/jquery/jquery-ui-1.10.3/tests/unit/tooltip/tooltip_core.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/jquery-ui-1.10.3/tests/unit/tooltip/tooltip_core.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 2 months ago) by torben
File MIME type: application/javascript
File size: 3776 byte(s)
initial import
1 (function( $ ) {
2
3 module( "tooltip: core" );
4
5 test( "markup structure", function() {
6 expect( 7 );
7 var element = $( "#tooltipped1" ).tooltip(),
8 tooltip = $( ".ui-tooltip" );
9
10 equal( element.attr( "aria-describedby" ), undefined, "no aria-describedby on init" );
11 equal( tooltip.length, 0, "no tooltip on init" );
12
13 element.tooltip( "open" );
14 tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
15 equal( tooltip.length, 1, "tooltip exists" );
16 equal( element.attr( "aria-describedby"), tooltip.attr( "id" ), "aria-describedby" );
17 ok( tooltip.hasClass( "ui-tooltip" ), "tooltip is .ui-tooltip" );
18 equal( tooltip.length, 1, ".ui-tooltip exists" );
19 equal( tooltip.find( ".ui-tooltip-content" ).length, 1,
20 ".ui-tooltip-content exists" );
21 });
22
23 test( "accessibility", function() {
24 expect( 5 );
25
26 var tooltipId,
27 tooltip,
28 element = $( "#multiple-describedby" ).tooltip();
29
30 element.tooltip( "open" );
31 tooltipId = element.data( "ui-tooltip-id" );
32 tooltip = $( "#" + tooltipId );
33 equal( tooltip.attr( "role" ), "tooltip", "role" );
34 equal( element.attr( "aria-describedby" ), "fixture-span " + tooltipId,
35 "multiple describedby when open" );
36 // strictEqual to distinguish between .removeAttr( "title" ) and .attr( "title", "" )
37 // support: jQuery <1.6.2
38 // support: IE <8
39 // We should use strictEqual( ..., undefined ) when dropping jQuery 1.6.1 support (or IE6/7)
40 ok( !element.attr( "title" ), "no title when open" );
41 element.tooltip( "close" );
42 equal( element.attr( "aria-describedby" ), "fixture-span",
43 "correct describedby when closed" );
44 equal( element.attr( "title" ), "...", "title restored when closed" );
45 });
46
47 test( "delegated removal", function() {
48 expect( 2 );
49
50 var container = $( "#contains-tooltipped" ).tooltip(),
51 element = $( "#contained-tooltipped" );
52
53 element.trigger( "mouseover" );
54 equal( $( ".ui-tooltip" ).length, 1 );
55
56 container.empty();
57 equal( $( ".ui-tooltip" ).length, 0 );
58 });
59
60 test( "nested tooltips", function() {
61 expect( 2 );
62
63 var child = $( "#contained-tooltipped" ),
64 parent = $( "#contains-tooltipped" ).tooltip({
65 show: null,
66 hide: null
67 });
68
69 parent.trigger( "mouseover" );
70 equal( $( ".ui-tooltip:visible" ).text(), "parent" );
71
72 child.trigger( "mouseover" );
73 equal( $( ".ui-tooltip" ).text(), "child" );
74 });
75
76 // #8742
77 test( "form containing an input with name title", function() {
78 expect( 4 );
79
80 var form = $( "#tooltip-form" ).tooltip({
81 show: null,
82 hide: null
83 }),
84 input = form.find( "[name=title]" );
85
86 equal( $( ".ui-tooltip" ).length, 0, "no tooltips on init" );
87
88 input.trigger( "mouseover" );
89 equal( $( ".ui-tooltip" ).length, 1, "tooltip for input" );
90 input.trigger( "mouseleave" );
91 equal( $( ".ui-tooltip" ).length, 0, "tooltip for input closed" );
92
93 form.trigger( "mouseover" );
94 equal( $( ".ui-tooltip" ).length, 0, "no tooltip for form" );
95 });
96
97 test( "tooltip on .ui-state-disabled element", function() {
98 expect( 2 );
99
100 var container = $( "#contains-tooltipped" ).tooltip(),
101 element = $( "#contained-tooltipped" ).addClass( "ui-state-disabled" );
102
103 element.trigger( "mouseover" );
104 equal( $( ".ui-tooltip" ).length, 1 );
105
106 container.empty();
107 equal( $( ".ui-tooltip" ).length, 0 );
108 });
109
110 // http://bugs.jqueryui.com/ticket/8740
111 asyncTest( "programmatic focus with async content", function() {
112 expect( 2 );
113 var element = $( "#tooltipped1" ).tooltip({
114 content: function( response ) {
115 setTimeout(function() {
116 response( "test" );
117 });
118 }
119 });
120
121 element.bind( "tooltipopen", function( event ) {
122 deepEqual( event.originalEvent.type, "focusin" );
123
124 element.bind( "tooltipclose", function( event ) {
125 deepEqual( event.originalEvent.type, "focusout" );
126 start();
127 });
128
129 setTimeout(function() {
130 element.blur();
131 });
132 });
133
134 element.focus();
135 });
136
137 }( jQuery ) );

  ViewVC Help
Powered by ViewVC 1.1.20