1
1
define ( [
2
+ "qunit" ,
2
3
"jquery" ,
3
4
"ui/widgets/tooltip"
4
- ] , function ( $ ) {
5
+ ] , function ( QUnit , $ ) {
5
6
6
- module ( "tooltip: core" ) ;
7
+ QUnit . module ( "tooltip: core" ) ;
7
8
8
- test ( "markup structure" , function ( assert ) {
9
- expect ( 7 ) ;
9
+ QUnit . test ( "markup structure" , function ( assert ) {
10
+ assert . expect ( 7 ) ;
10
11
var element = $ ( "#tooltipped1" ) . tooltip ( ) ,
11
12
tooltip = $ ( ".ui-tooltip" ) ;
12
13
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" ) ;
15
16
16
17
element . tooltip ( "open" ) ;
17
18
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" ) ;
20
21
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 . length , 1 , ".ui-tooltip exists" ) ;
23
+ assert . equal ( tooltip . find ( ".ui-tooltip-content" ) . length , 1 ,
23
24
".ui-tooltip-content exists" ) ;
24
25
} ) ;
25
26
26
- test ( "accessibility" , function ( ) {
27
- expect ( 15 ) ;
27
+ QUnit . test ( "accessibility" , function ( assert ) {
28
+ assert . expect ( 15 ) ;
28
29
29
30
var tooltipId , tooltip ,
30
31
element = $ ( "#multiple-describedby" ) . tooltip ( ) ,
31
32
liveRegion = element . tooltip ( "instance" ) . liveRegion ;
32
33
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" ) ;
37
38
element . tooltip ( "open" ) ;
38
39
tooltipId = element . data ( "ui-tooltip-id" ) ;
39
40
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 ,
42
43
"multiple describedby when open" ) ;
43
44
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 ( ) , "..." ) ;
47
48
element . tooltip ( "close" ) ;
48
- equal ( element . attr ( "aria-describedby" ) , "fixture-span" ,
49
+ assert . equal ( element . attr ( "aria-describedby" ) , "fixture-span" ,
49
50
"correct describedby when closed" ) ;
50
- equal ( element . attr ( "title" ) , "..." , "title restored when closed" ) ;
51
+ assert . equal ( element . attr ( "title" ) , "..." , "title restored when closed" ) ;
51
52
52
53
element . tooltip ( "open" ) ;
53
- equal ( liveRegion . children ( ) . length , 2 ,
54
+ assert . equal ( liveRegion . children ( ) . length , 2 ,
54
55
"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 ,
56
57
"Only one of the children should be visible" ) ;
57
- ok ( liveRegion . children ( ) . last ( ) . is ( ":visible" ) ,
58
+ assert . ok ( liveRegion . children ( ) . last ( ) . is ( ":visible" ) ,
58
59
"Only the last child should be visible" ) ;
59
60
element . tooltip ( "close" ) ;
60
61
61
62
element . tooltip ( "destroy" ) ;
62
- equal ( liveRegion . parent ( ) . length , 0 ,
63
+ assert . equal ( liveRegion . parent ( ) . length , 0 ,
63
64
"Tooltip liveregion element should be removed" ) ;
64
65
} ) ;
65
66
66
- test ( "delegated removal" , function ( ) {
67
- expect ( 2 ) ;
67
+ QUnit . test ( "delegated removal" , function ( assert ) {
68
+ assert . expect ( 2 ) ;
68
69
69
70
var container = $ ( "#contains-tooltipped" ) . tooltip ( ) ,
70
71
element = $ ( "#contained-tooltipped" ) ;
71
72
72
73
element . trigger ( "mouseover" ) ;
73
- equal ( $ ( ".ui-tooltip" ) . length , 1 ) ;
74
+ assert . equal ( $ ( ".ui-tooltip" ) . length , 1 ) ;
74
75
75
76
container . empty ( ) ;
76
- equal ( $ ( ".ui-tooltip" ) . length , 0 ) ;
77
+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 ) ;
77
78
} ) ;
78
79
79
- test ( "nested tooltips" , function ( ) {
80
- expect ( 2 ) ;
80
+ QUnit . test ( "nested tooltips" , function ( assert ) {
81
+ assert . expect ( 2 ) ;
81
82
82
83
var child = $ ( "#contained-tooltipped" ) ,
83
84
parent = $ ( "#contains-tooltipped" ) . tooltip ( {
@@ -86,49 +87,50 @@ test( "nested tooltips", function() {
86
87
} ) ;
87
88
88
89
parent . trigger ( "mouseover" ) ;
89
- equal ( $ ( ".ui-tooltip:visible" ) . text ( ) , "parent" ) ;
90
+ assert . equal ( $ ( ".ui-tooltip:visible" ) . text ( ) , "parent" ) ;
90
91
91
92
child . trigger ( "mouseover" ) ;
92
- equal ( $ ( ".ui-tooltip" ) . text ( ) , "child" ) ;
93
+ assert . equal ( $ ( ".ui-tooltip" ) . text ( ) , "child" ) ;
93
94
} ) ;
94
95
95
96
// #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 ) ;
98
99
99
100
var form = $ ( "#tooltip-form" ) . tooltip ( {
100
101
show : null ,
101
102
hide : null
102
103
} ) ,
103
104
input = form . find ( "[name=title]" ) ;
104
105
105
- equal ( $ ( ".ui-tooltip" ) . length , 0 , "no tooltips on init" ) ;
106
+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 , "no tooltips on init" ) ;
106
107
107
108
input . trigger ( "mouseover" ) ;
108
- equal ( $ ( ".ui-tooltip" ) . length , 1 , "tooltip for input" ) ;
109
+ assert . equal ( $ ( ".ui-tooltip" ) . length , 1 , "tooltip for input" ) ;
109
110
input . trigger ( "mouseleave" ) ;
110
- equal ( $ ( ".ui-tooltip" ) . length , 0 , "tooltip for input closed" ) ;
111
+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 , "tooltip for input closed" ) ;
111
112
112
113
form . trigger ( "mouseover" ) ;
113
- equal ( $ ( ".ui-tooltip" ) . length , 0 , "no tooltip for form" ) ;
114
+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 , "no tooltip for form" ) ;
114
115
} ) ;
115
116
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 ) ;
118
119
119
120
var container = $ ( "#contains-tooltipped" ) . tooltip ( ) ,
120
121
element = $ ( "#contained-tooltipped" ) . addClass ( "ui-state-disabled" ) ;
121
122
122
123
element . trigger ( "mouseover" ) ;
123
- equal ( $ ( ".ui-tooltip" ) . length , 1 ) ;
124
+ assert . equal ( $ ( ".ui-tooltip" ) . length , 1 ) ;
124
125
125
126
container . empty ( ) ;
126
- equal ( $ ( ".ui-tooltip" ) . length , 0 ) ;
127
+ assert . equal ( $ ( ".ui-tooltip" ) . length , 0 ) ;
127
128
} ) ;
128
129
129
130
// 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 ) ;
132
134
var element = $ ( "#tooltipped1" ) . tooltip ( {
133
135
content : function ( response ) {
134
136
setTimeout ( function ( ) {
@@ -138,11 +140,11 @@ asyncTest( "programmatic focus with async content", function() {
138
140
} ) ;
139
141
140
142
element . on ( "tooltipopen" , function ( event ) {
141
- deepEqual ( event . originalEvent . type , "focusin" ) ;
143
+ assert . deepEqual ( event . originalEvent . type , "focusin" ) ;
142
144
143
145
element . on ( "tooltipclose" , function ( event ) {
144
- deepEqual ( event . originalEvent . type , "focusout" ) ;
145
- start ( ) ;
146
+ assert . deepEqual ( event . originalEvent . type , "focusout" ) ;
147
+ ready ( ) ;
146
148
} ) ;
147
149
148
150
setTimeout ( function ( ) {
@@ -153,29 +155,31 @@ asyncTest( "programmatic focus with async content", function() {
153
155
element . trigger ( "focus" ) ;
154
156
} ) ;
155
157
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 ) ;
158
161
159
162
var element = $ ( "#tooltipped1" ) . tooltip ( {
160
163
show : false ,
161
164
hide : true
162
165
} ) ;
163
166
164
167
element . on ( "tooltipclose" , function ( ) {
165
- ok ( true , "tooltip closed" ) ;
168
+ assert . ok ( true , "tooltip closed" ) ;
166
169
} ) ;
167
170
168
171
element . tooltip ( "open" ) ;
169
172
element . tooltip ( "close" ) ;
170
173
setTimeout ( function ( ) {
171
174
element . tooltip ( "destroy" ) ;
172
- start ( ) ;
175
+ ready ( ) ;
173
176
} ) ;
174
177
} ) ;
175
178
176
179
// 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 ) ;
179
183
180
184
var anchor = $ ( "#tooltipped1" ) ,
181
185
input = anchor . next ( ) ,
@@ -209,21 +213,21 @@ asyncTest( "multiple active delegated tooltips", function() {
209
213
210
214
function step4 ( ) {
211
215
anchor . simulate ( "mouseout" ) ;
212
- deepEqual ( actions , [
216
+ assert . deepEqual ( actions , [
213
217
"open:anchortitle" ,
214
218
"open:inputtitle" ,
215
219
"close:inputtitle" ,
216
220
"close:anchortitle"
217
221
] , "Both tooltips open and close" ) ;
218
- start ( ) ;
222
+ ready ( ) ;
219
223
}
220
224
221
225
step1 ( ) ;
222
226
} ) ;
223
227
224
228
// 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 ) ;
227
231
228
232
var element = $ (
229
233
"<div id='content'>" +
@@ -237,9 +241,9 @@ test( "remove conflicting attributes from live region", function() {
237
241
. tooltip ( {
238
242
content : element ,
239
243
open : function ( ) {
240
- equal ( $ ( ".ui-helper-hidden-accessible [name]" ) . length , 0 ,
244
+ assert . equal ( $ ( ".ui-helper-hidden-accessible [name]" ) . length , 0 ,
241
245
"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 ,
243
247
"no id attributes within live region" ) ;
244
248
}
245
249
} )
0 commit comments