11define ( [
2+ "qunit" ,
23 "jquery" ,
34 "ui/widgets/tooltip"
4- ] , function ( $ ) {
5+ ] , function ( QUnit , $ ) {
56
6- module ( "tooltip: core" ) ;
7+ QUnit . module ( "tooltip: core" ) ;
78
8- test ( "markup structure" , function ( assert ) {
9- expect ( 7 ) ;
9+ QUnit . test ( "markup structure" , function ( assert ) {
10+ assert . expect ( 7 ) ;
1011 var element = $ ( "#tooltipped1" ) . tooltip ( ) ,
1112 tooltip = $ ( ".ui-tooltip" ) ;
1213
13- equal ( element . attr ( "aria-describedby" ) , undefined , "no aria-describedby on init" ) ;
14- equal ( tooltip . length , 0 , "no tooltip on init" ) ;
14+ assert . equal ( element . attr ( "aria-describedby" ) , undefined , "no aria-describedby on init" ) ;
15+ assert . equal ( tooltip . length , 0 , "no tooltip on init" ) ;
1516
1617 element . tooltip ( "open" ) ;
1718 tooltip = $ ( "#" + element . data ( "ui-tooltip-id" ) ) ;
18- equal ( tooltip . length , 1 , "tooltip exists" ) ;
19- equal ( element . attr ( "aria-describedby" ) , tooltip . attr ( "id" ) , "aria-describedby" ) ;
19+ assert . equal ( tooltip . length , 1 , "tooltip exists" ) ;
20+ assert . equal ( element . attr ( "aria-describedby" ) , tooltip . attr ( "id" ) , "aria-describedby" ) ;
2021 assert . hasClasses ( tooltip , "ui-tooltip ui-widget ui-widget-content ui-widget-shadow" ) ;
21- equal ( tooltip . length , 1 , ".ui-tooltip exists" ) ;
22- equal ( tooltip . find ( ".ui-tooltip-content" ) . length , 1 ,
22+ assert . equal ( tooltip .
8096
length , 1 , ".ui-tooltip exists" ) ;
23+ assert . equal ( tooltip . find ( ".ui-tooltip-content" ) . length , 1 ,
2324 ".ui-tooltip-content exists" ) ;
2425} ) ;
2526
26- test ( "accessibility" , function ( ) {
27- expect ( 15 ) ;
27+ QUnit . test ( "accessibility" , function ( assert ) {
28+ assert . expect ( 15 ) ;
2829
2930 var tooltipId , tooltip ,
3031 element = $ ( "#multiple-describedby" ) . tooltip ( ) ,
3132 liveRegion = element . tooltip ( "instance" ) . liveRegion ;
3233
33- equal ( liveRegion . find ( ">div" ) . length , 0 ) ;
34- equal ( liveRegion . attr ( "role" ) , "log" ) ;
35- equal ( liveRegion . attr ( "aria-live" ) , "assertive" ) ;
36- equal ( liveRegion . attr ( "aria-relevant" ) , "additions" ) ;
34+ assert . equal ( liveRegion . find ( ">div" ) . length , 0 ) ;
35+ assert . equal ( liveRegion . attr ( "role" ) , "log" ) ;
36+ assert . equal ( liveRegion . attr ( "aria-live" ) , "assertive" ) ;
37+ assert . equal ( liveRegion . attr ( "aria-relevant" ) , "additions" ) ;
3738 element . tooltip ( "open" ) ;
3839 tooltipId = element . data ( "ui-tooltip-id" ) ;
3940 tooltip = $ ( "#" + tooltipId ) ;
40- equal ( tooltip . attr ( "role" ) , "tooltip" , "role" ) ;
41- equal ( element . attr ( "aria-describedby" ) , "fixture-span " + tooltipId ,
41+ assert . equal ( tooltip . attr ( "role" ) , "tooltip" , "role" ) ;
42+ assert . equal ( element . attr ( "aria-describedby" ) , "fixture-span " + tooltipId ,
4243 "multiple describedby when open" ) ;
4344
44- equal ( element . attr ( "title" ) , null , "no title when open" ) ;
45- equal ( liveRegion . children ( ) . length , 1 ) ;
46- equal ( liveRegion . children ( ) . last ( ) . html ( ) , "..." ) ;
45+ assert . equal ( element . attr ( "title" ) , null , "no title when open" ) ;
46+ assert . equal ( liveRegion . children ( ) . length , 1 ) ;
47+ assert . equal ( liveRegion . children ( ) . last ( ) . html ( ) , "..." ) ;
4748 element . tooltip ( "close" ) ;
48- equal ( element . attr ( "aria-describedby" ) , "fixture-span" ,
49+ assert . equal ( element . attr ( "aria-describedby" ) , "fixture-span" ,
4950 "correct describedby when closed" ) ;
50- equal ( element . attr ( "title" ) , "..." , "title restored when closed" ) ;
51+ assert . equal ( element . attr ( "title" ) , "..." , "title restored when closed" ) ;
5152
5253 element . tooltip ( "open" ) ;
53- equal ( liveRegion . children ( ) . length , 2 ,
54+ assert . equal ( liveRegion . children ( ) . length , 2 ,
5455 "After the second tooltip show, there should be two children" ) ;
55- equal ( liveRegion . children ( ) . filter ( ":visible" ) . length , 1 ,
56+ assert . equal ( liveRegion . children ( ) . filter ( ":visible" ) . length , 1 ,
5657 "Only one of the children should be visible" ) ;
57- ok ( liveRegion . children ( ) . last ( ) . is ( ":visible" ) ,
58+ assert . ok ( liveRegion . children ( ) . last ( ) . is ( ":visible" ) ,
5859 "Only the last child should be visible" ) ;
5960 element . tooltip ( "close" ) ;
6061
6162 element . tooltip ( "destroy" ) ;
62- equal ( liveRegion . parent ( ) . length , 0 ,
63+ assert . equal ( liveRegion . parent ( ) . length , 0 ,
6364 "Tooltip liveregion element should be removed" ) ;
6465} ) ;
6566
66- test ( "delegated removal" , function ( ) {
67- expect ( 2 ) ;
67+ QUnit . test ( "delegated removal" , function ( assert ) {
68+ assert . expect ( 2 ) ;
6869
6970 var container = $ ( "#contains-tooltipped" ) . tooltip ( ) ,
7071 element = $ ( "#contained-tooltipped" ) ;
7172
7273 element . trigger ( "mouseover" ) ;
73- equal ( $ ( ".ui-tooltip" ) . length , 1 ) ;
74+ assert . equal ( $ ( ".ui-tooltip" ) . length , 1 ) ;
7475
7576 container . empty ( ) ;
76- equal ( $ ( ".ui-tooltip" ) . length , 0 ) ;
77+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 ) ;
7778} ) ;
7879
79- test ( "nested tooltips" , function ( ) {
80- expect ( 2 ) ;
80+ QUnit . test ( "nested tooltips" , function ( assert ) {
81+ assert . expect ( 2 ) ;
8182
8283 var child = $ ( "#contained-tooltipped" ) ,
8384 parent = $ ( "#contains-tooltipped" ) . tooltip ( {
@@ -86,49 +87,50 @@ test( "nested tooltips", function() {
8687 } ) ;
8788
8889 parent . trigger ( "mouseover" ) ;
89- equal ( $ ( ".ui-tooltip:visible" ) . text ( ) , "parent" ) ;
90+ assert . equal ( $ ( ".ui-tooltip:visible" ) . text ( ) , "parent" ) ;
9091
9192 child . trigger ( "mouseover" ) ;
92- equal ( $ ( ".ui-tooltip" ) . text ( ) , "child" ) ;
93+ assert . equal ( $ ( ".ui-tooltip" ) . text ( ) , "child" ) ;
9394} ) ;
9495
9596// #8742
96- test ( "form containing an input with name title" , function ( ) {
97- expect ( 4 ) ;
97+ QUnit . test ( "form containing an input with name title" , function ( assert ) {
98+ assert . expect ( 4 ) ;
9899
99100 var form = $ ( "#tooltip-form" ) . tooltip ( {
100101 show : null ,
101102 hide : null
102103 } ) ,
103104 input = form . find ( "[name=title]" ) ;
104105
105- equal ( $ ( ".ui-tooltip" ) . length , 0 , "no tooltips on init" ) ;
6865
106+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 , "no tooltips on init" ) ;
106107
107108 input . trigger ( "mouseover" ) ;
108- equal ( $ ( ".ui-tooltip" ) . length , 1 , "tooltip for input" ) ;
109+ assert . equal ( $ ( ".ui-tooltip" ) . length , 1 , "tooltip for input" ) ;
109110 input . trigger ( "mouseleave" ) ;
110- equal ( $ ( ".ui-tooltip" ) . length , 0 , "tooltip for input closed" ) ;
111+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 , "tooltip for input closed" ) ;
111112
112113 form . trigger ( "mouseover" ) ;
113- equal ( $ ( ".ui-tooltip" ) . length , 0 , "no tooltip for form" ) ;
114+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 , "no tooltip for form" ) ;
114115} ) ;
115116
116- test ( "tooltip on .ui-state-disabled element" , function ( ) {
117- expect ( 2 ) ;
117+ QUnit . test ( "tooltip on .ui-state-disabled element" , function ( assert ) {
118+ assert . expect ( 2 ) ;
118119
119120 var container = $ ( "#contains-tooltipped" ) . tooltip ( ) ,
120121 element = $ ( "#contained-tooltipped" ) . addClass ( "ui-state-disabled" ) ;
121122
122123 element . trigger ( "mouseover" ) ;
123- equal ( $ ( ".ui-tooltip" ) . length , 1 ) ;
124+ assert . equal ( $ ( ".ui-tooltip" ) . length , 1 ) ;
124125
125126 container . empty ( ) ;
126- equal ( $ ( ".ui-tooltip" ) . length , 0 ) ;
127+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 ) ;
127128} ) ;
128129
129130// http://bugs.jqueryui.com/ticket/8740
130- asyncTest ( "programmatic focus with async content" , function ( ) {
131- expect ( 2 ) ;
131+ QUnit . test ( "programmatic focus with async content" , function ( assert ) {
132+ var ready = assert . async ( ) ;
133+ assert . expect ( 2 ) ;
132134 var element = $ ( "#tooltipped1" ) . tooltip ( {
133135 content : function ( response ) {
134136 setTimeout ( function ( ) {
@@ -138,11 +140,11 @@ asyncTest( "programmatic focus with async content", function() {
138140 } ) ;
139141
140142 element . on ( "tooltipopen" , function ( event ) {
141- deepEqual ( event . originalEvent . type , "focusin" ) ;
143+ assert . deepEqual ( event . originalEvent . type , "focusin" ) ;
142144
143145 element . on ( "tooltipclose" , function ( event ) {
144- deepEqual ( event . originalEvent . type , "focusout" ) ;
145- start ( ) ;
146+ assert . deepEqual ( event . originalEvent . type , "focusout" ) ;
147+ ready ( ) ;
146148 } ) ;
147149
148150 setTimeout ( function ( ) {
@@ -153,29 +155,31 @@ asyncTest( "programmatic focus with async content", function() {
153155 element . trigger ( "focus" ) ;
154156} ) ;
155157
156- asyncTest ( "destroy during hide animation; only one close event" , function ( ) {
157- expect ( 1 ) ;
158+ QUnit . test ( "destroy during hide animation; only one close event" , function ( assert ) {
159+ var ready = assert . async ( ) ;
160+ assert . expect ( 1 ) ;
158161
159162 var element = $ ( "#tooltipped1" ) . tooltip ( {
160163 show : false ,
161164 hide : true
162165 } ) ;
163166
164167 element . on ( "tooltipclose" , function ( ) {
165- ok ( true , "tooltip closed" ) ;
168+ assert . ok ( true , "tooltip closed" ) ;
166169 } ) ;
167170
168171 element . tooltip ( "open" ) ;
169172 element . tooltip ( "close" ) ;
170173 setTimeout ( function ( ) {
171174 element . tooltip ( "destroy" ) ;
172- start ( ) ;
175+ ready ( ) ;
173176 } ) ;
174177} ) ;
175178
176179// http://bugs.jqueryui.com/ticket/10602
177- asyncTest ( "multiple active delegated tooltips" , function ( ) {
178- expect ( 1 ) ;
180+ QUnit . test ( "multiple active delegated tooltips" , function ( assert ) {
181+ var ready = assert . async ( ) ;
182+ assert . expect ( 1 ) ;
179183
180184 var anchor = $ ( "#tooltipped1" ) ,
181185 input = anchor . next ( ) ,
@@ -209,21 +213,21 @@ asyncTest( "multiple active delegated tooltips", function() {
209213
210214 function step4 ( ) {
211215 anchor . simulate ( "mouseout" ) ;
212- deepEqual ( actions , [
216+ assert . deepEqual ( actions , [
213217 "open:anchortitle" ,
214218 "open:inputtitle" ,
215219 "close:inputtitle" ,
216220 "close:anchortitle"
217221 ] , "Both tooltips open and close" ) ;
218- start ( ) ;
222+ ready ( ) ;
219223 }
220224
221225 step1 ( ) ;
222226} ) ;
223227
224228// http://bugs.jqueryui.com/ticket/11272
225- test ( "remove conflicting attributes from live region" , function ( ) {
226- expect ( 2 ) ;
229+ QUnit . test ( "remove conflicting attributes from live region" , function ( assert ) {
230+ assert . expect ( 2 ) ;
227231
228232 var element = $ (
229233 "<div id='content'>" +
@@ -237,9 +241,9 @@ test( "remove conflicting attributes from live region", function() {
237241 . tooltip ( {
238242 content : element ,
239243 open : function ( ) {
240- equal ( $ ( ".ui-helper-hidden-accessible [name]" ) . length , 0 ,
244+ assert . equal ( $ ( ".ui-helper-hidden-accessible [name]" ) . length , 0 ,
241245 "no name attributes within live region" ) ;
242- equal ( $ ( ".ui-helper-hidden-accessible [id]" ) . length , 0 ,
246+ assert . equal ( $ ( ".ui-helper-hidden-accessible [id]" ) . length , 0 ,
243247 "no id attributes within live region" ) ;
244248 }
245249 } )
0 commit comments