6
6
module ( "core - selectors" ) ;
7
7
8
8
function isFocusable ( selector , msg ) {
9
- ok ( $ ( selector ) . is ( ':focusable' ) , msg + " - selector " + selector + " is focusable" ) ;
9
+ QUnit . push ( $ ( selector ) . is ( ':focusable' ) , null , null , msg + " - selector " + selector + " is focusable" ) ;
10
10
}
11
11
12
12
function isNotFocusable ( selector , msg ) {
13
- ok ( $ ( selector ) . length && ! $ ( selector ) . is ( ':focusable' ) , msg + " - selector " + selector + " is not focusable" ) ;
13
+ QUnit . push ( $ ( selector ) . length && ! $ ( selector ) . is ( ':focusable' ) , null , null , msg + " - selector " + selector + " is not focusable" ) ;
14
14
}
15
15
16
16
function isTabbable ( selector , msg ) {
17
- ok ( $ ( selector ) . is ( ':tabbable' ) , msg + " - selector " + selector + " is tabbable" ) ;
17
+ QUnit . push ( $ ( selector ) . is ( ':tabbable' ) , null , null , msg + " - selector " + selector + " is tabbable" ) ;
18
18
}
19
19
20
20
function isNotTabbable ( selector , msg ) {
21
- ok ( $ ( selector ) . length && ! $ ( selector ) . is ( ':tabbable' ) , msg + " - selector " + selector + " is not tabbable" ) ;
21
+ QUnit . push ( $ ( selector ) . length && ! $ ( selector ) . is ( ':tabbable' ) , null , null , msg + " - selector " + selector + " is not tabbable" ) ;
22
22
}
23
23
24
24
test ( "data" , function ( ) {
25
25
expect ( 15 ) ;
26
-
26
+
27
27
var el ;
28
28
function shouldHaveData ( msg ) {
29
29
ok ( el . is ( ':data(test)' ) , msg ) ;
30
30
}
31
31
function shouldNotHaveData ( msg ) {
32
32
ok ( ! el . is ( ':data(test)' ) , msg ) ;
33
33
}
34
-
34
+
35
35
el = $ ( '<div>' ) ;
36
36
shouldNotHaveData ( 'data never set' ) ;
37
-
37
+
38
38
el = $ ( '<div>' ) . data ( 'test' , null ) ;
39
39
shouldNotHaveData ( 'data is null' ) ;
40
-
40
+
41
41
el = $ ( '<div>' ) . data ( 'test' , true ) ;
42
42
shouldHaveData ( 'data set to true' ) ;
43
-
43
+
44
44
el = $ ( '<div>' ) . data ( 'test' , false ) ;
45
45
shouldNotHaveData ( 'data set to false' ) ;
46
-
46
+
47
47
el = $ ( '<div>' ) . data ( 'test' , 0 ) ;
48
48
shouldNotHaveData ( 'data set to 0' ) ;
49
-
49
+
50
50
el = $ ( '<div>' ) . data ( 'test' , 1 ) ;
51
51
shouldHaveData ( 'data set to 1' ) ;
52
-
52
+
53
53
el = $ ( '<div>' ) . data ( 'test' , '' ) ;
54
54
shouldNotHaveData ( 'data set to empty string' ) ;
55
-
55
+
56
56
el = $ ( '<div>' ) . data ( 'test' , 'foo' ) ;
57
57
shouldHaveData ( 'data set to string' ) ;
58
-
58
+
59
59
el = $ ( '<div>' ) . data ( 'test' , [ ] ) ;
60
60
shouldHaveData ( 'data set to empty array' ) ;
61
-
61
+
62
62
el = $ ( '<div>' ) . data ( 'test' , [ 1 ] ) ;
63
63
shouldHaveData ( 'data set to array' ) ;
64
-
64
+
65
65
el = $ ( '<div>' ) . data ( 'test' , { } ) ;
66
66
shouldHaveData ( 'data set to empty object' ) ;
67
-
67
+
68
68
el = $ ( '<div>' ) . data ( 'test' , { foo : 'bar' } ) ;
69
69
shouldHaveData ( 'data set to object' ) ;
70
-
70
+
71
71
el = $ ( '<div>' ) . data ( 'test' , new Date ( ) ) ;
72
72
shouldHaveData ( 'data set to date' ) ;
73
-
73
+
74
74
el = $ ( '<div>' ) . data ( 'test' , / t e s t / ) ;
75
75
shouldHaveData ( 'data set to regexp' ) ;
76
-
76
+
77
77
el = $ ( '<div>' ) . data ( 'test' , function ( ) { } ) ;
78
78
shouldHaveData ( 'data set to function' ) ;
79
79
} ) ;
80
80
81
81
test ( "focusable - visible, enabled elements" , function ( ) {
82
82
expect ( 18 ) ;
83
-
83
+
84
84
isNotFocusable ( '#formNoTabindex' , 'form' ) ;
85
85
isFocusable ( '#formTabindex' , 'form with tabindex' ) ;
86
86
isFocusable ( '#visibleAncestor-inputTypeNone' , 'input, no type' ) ;
@@ -103,7 +103,7 @@ test("focusable - visible, enabled elements", function() {
103
103
104
104
test ( "focusable - disabled elements" , function ( ) {
105
105
expect ( 9 ) ;
106
-
106
+
107
107
isNotFocusable ( '#disabledElement-inputTypeNone' , 'input, no type' ) ;
108
108
isNotFocusable ( '#disabledElement-inputTypeText' , 'input, type text' ) ;
109
109
isNotFocusable ( '#disabledElement-inputTypeCheckbox' , 'input, type checkbox' ) ;
@@ -117,23 +117,23 @@ test("focusable - disabled elements", function() {
117
117
118
118
test ( "focusable - hidden styles" , function ( ) {
119
119
expect ( 8 ) ;
120
-
120
+
121
121
isNotFocusable ( '#displayNoneAncestor-input' , 'input, display: none parent' ) ;
122
122
isNotFocusable ( '#displayNoneAncestor-span' , 'span with tabindex, display: none parent' ) ;
123
-
123
+
124
124
isNotFocusable ( '#visibilityHiddenAncestor-input' , 'input, visibility: hidden parent' ) ;
125
125
isNotFocusable ( '#visibilityHiddenAncestor-span' , 'span with tabindex, visibility: hidden parent' ) ;
126
-
126
+
127
127
isNotFocusable ( '#displayNone-input' , 'input, display: none' ) ;
128
128
isNotFocusable ( '#visibilityHidden-input' , 'input, visibility: hidden' ) ;
129
-
129
+
130
130
isNotFocusable ( '#displayNone-span' , 'span with tabindex, display: none' ) ;
131
131
isNotFocusable ( '#visibilityHidden-span' , 'span with tabindex, visibility: hidden' ) ;
132
132
} ) ;
133
133
134
134
test ( "focusable - natively focusable with various tabindex" , function ( ) {
135
135
expect ( 4 ) ;
136
-
136
+
137
137
isFocusable ( '#inputTabindex0' , 'input, tabindex 0' ) ;
138
138
isFocusable ( '#inputTabindex10' , 'input, tabindex 10' ) ;
139
139
isFocusable ( '#inputTabindex-1' , 'input, tabindex -1' ) ;
@@ -142,24 +142,22 @@ test("focusable - natively focusable with various tabindex", function() {
142
142
143
143
test ( "focusable - not natively focusable with various tabindex" , function ( ) {
144
144
expect ( 4 ) ;
145
-
145
+
146
146
isFocusable ( '#spanTabindex0' , 'span, tabindex 0' ) ;
147
147
isFocusable ( '#spanTabindex10' , 'span, tabindex 10' ) ;
148
148
isFocusable ( '#spanTabindex-1' , 'span, tabindex -1' ) ;
149
149
isFocusable ( '#spanTabindex-50' , 'span, tabindex -50' ) ;
150
150
} ) ;
151
151
152
152
test ( "focusable - area elements" , function ( ) {
153
- isNotFocusable ( '#areaCoordsNoHref' , 'coords but no href' ) ;
154
153
isFocusable ( '#areaCoordsHref' , 'coords and href' ) ;
155
- isFocusable ( '#areaCoordsNoSizeHref' , 'coords of zero px and href' ) ;
156
154
isFocusable ( '#areaNoCoordsHref' , 'href but no coords' ) ;
157
155
isNotFocusable ( '#areaNoImg' , 'not associated with an image' ) ;
158
156
} ) ;
159
157
160
158
test ( "tabbable - visible, enabled elements" , function ( ) {
161
159
expect ( 18 ) ;
162
-
160
+
163
161
isNotTabbable ( '#formNoTabindex' , 'form' ) ;
164
162
isTabbable ( '#formTabindex' , 'form with tabindex' ) ;
165
163
isTabbable ( '#visibleAncestor-inputTypeNone' , 'input, no type' ) ;
@@ -182,7 +180,7 @@ test("tabbable - visible, enabled elements", function() {
182
180
183
181
test ( "tabbable - disabled elements" , function ( ) {
184
182
expect ( 9 ) ;
185
-
183
+
186
184
isNotTabbable ( '#disabledElement-inputTypeNone' , 'input, no type' ) ;
187
185
isNotTabbable ( '#disabledElement-inputTypeText' , 'input, type text' ) ;
188
186
isNotTabbable ( '#disabledElement-inputTypeCheckbox' , 'input, type checkbox' ) ;
@@ -196,23 +194,23 @@ test("tabbable - disabled elements", function() {
196
194
197
195
test ( "tabbable - hidden styles" , function ( ) {
198
196
expect ( 8 ) ;
199
-
197
+
200
198
isNotTabbable ( '#displayNoneAncestor-input' , 'input, display: none parent' ) ;
201
199
isNotTabbable ( '#displayNoneAncestor-span' , 'span with tabindex, display: none parent' ) ;
202
-
200
+
203
201
isNotTabbable ( '#visibilityHiddenAncestor-input' , 'input, visibility: hidden parent' ) ;
204
202
isNotTabbable ( '#visibilityHiddenAncestor-span' , 'span with tabindex, visibility: hidden parent' ) ;
205
-
203
+
206
204
isNotTabbable ( '#displayNone-input' , 'input, display: none' ) ;
207
205
isNotTabbable ( '#visibilityHidden-input' , 'input, visibility: hidden' ) ;
208
-
206
+
209
207
isNotTabbable ( '#displayNone-span' , 'span with tabindex, display: none' ) ;
210
208
isNotTabbable ( '#visibilityHidden-span' , 'span with tabindex, visibility: hidden' ) ;
211
209
} ) ;
212
210
213
211
test ( "tabbable - natively tabbable with various tabindex" , function ( ) {
214
212
expect ( 4 ) ;
215
-
213
+
216
214
isTabbable ( '#inputTabindex0' , 'input, tabindex 0' ) ;
217
215
isTabbable ( '#inputTabindex10' , 'input, tabindex 10' ) ;
218
216
isNotTabbable ( '#inputTabindex-1' , 'input, tabindex -1' ) ;
@@ -221,17 +219,15 @@ test("tabbable - natively tabbable with various tabindex", function() {
221
219
222
220
test ( "tabbable - not natively tabbable with various tabindex" , function ( ) {
223
221
expect ( 4 ) ;
224
-
222
+
225
223
isTabbable ( '#spanTabindex0' , 'span, tabindex 0' ) ;
226
224
isTabbable ( '#spanTabindex10' , 'span, tabindex 10' ) ;
227
225
isNotTabbable ( '#spanTabindex-1' , 'span, tabindex -1' ) ;
228
226
isNotTabbable ( '#spanTabindex-50' , 'span, tabindex -50' ) ;
229
227
} ) ;
230
228
231
229
test ( "tabbable - area elements" , function ( ) {
232
- isNotTabbable ( '#areaCoordsNoHref' , 'coords but no href' ) ;
233
230
isTabbable ( '#areaCoordsHref' , 'coords and href' ) ;
234
- isTabbable ( '#areaCoordsNoSizeHref' , 'coords of zero px and href' ) ;
235
231
isTabbable ( '#areaNoCoordsHref' , 'href but no coords' ) ;
236
232
isNotTabbable ( '#areaNoImg' , 'not associated with an image' ) ;
237
233
} ) ;
0 commit comments