@@ -5,8 +5,7 @@ define( [
5
5
"ui/widgets/datepicker" ,
6
6
"ui/i18n/datepicker-fr" ,
7
7
"ui/i18n/datepicker-he" ,
8
- "ui/i18n/datepicker-zh-CN" ,
9
- "ui/ie"
8
+ "ui/i18n/datepicker-zh-CN"
10
9
] , function ( QUnit , $ , testHelper ) {
11
10
"use strict" ;
12
11
@@ -97,147 +96,131 @@ QUnit.test( "change", function( assert ) {
97
96
assert . equal ( $ . datepicker . _defaults . showOn , "focus" , "Retain default showOn" ) ;
98
97
} ) ;
99
98
100
- ( function ( ) {
101
- var url = window . location . search ;
102
- url = decodeURIComponent ( url . slice ( url . indexOf ( "swarmURL=" ) + 9 ) ) ;
99
+ QUnit . test ( "invocation" , function ( assert ) {
100
+ var ready = assert . async ( ) ;
101
+ var button , image ,
102
+ body = $ ( "body" ) ;
103
103
104
- // TODO: This test occassionally fails in IE in TestSwarm
105
- if ( $ . ui . ie && url && url . indexOf ( "http" ) === 0 ) {
106
- return ;
107
- }
104
+ assert . expect ( 29 ) ;
108
105
109
- QUnit . test ( "invocation" , function ( assert ) {
110
- var ready = assert . async ( ) ;
111
- var button , image ,
112
- isOldIE = $ . ui . ie && ( ! document . documentMode || document . documentMode < 9 ) ,
113
- body = $ ( "body" ) ;
114
-
115
- assert . expect ( isOldIE ? 25 : 29 ) ;
116
-
117
- function step0 ( ) {
118
- var inp = testHelper . initNewInput ( ) ,
119
- dp = $ ( "#ui-datepicker-div" ) ;
120
-
121
- button = inp . siblings ( "button" ) ;
122
- assert . ok ( button . length === 0 , "Focus - button absent" ) ;
123
- image = inp . siblings ( "img" ) ;
124
- assert . ok ( image . length === 0 , "Focus - image absent" ) ;
125
-
126
- testHelper . onFocus ( inp , function ( ) {
127
- assert . ok ( dp . is ( ":visible" ) , "Focus - rendered on focus" ) ;
128
- inp . simulate ( "keydown" , { keyCode : $ . ui . keyCode . ESCAPE } ) ;
129
- assert . ok ( ! dp . is ( ":visible" ) , "Focus - hidden on exit" ) ;
130
- step1 ( ) ;
131
- } ) ;
132
- }
106
+ function step0 ( ) {
107
+ var inp = testHelper . initNewInput ( ) ,
108
+ dp = $ ( "#ui-datepicker-div" ) ;
133
109
134
- function step1 ( ) {
110
+ button = inp . siblings ( "button" ) ;
111
+ assert . ok ( button . length === 0 , "Focus - button absent" ) ;
112
+ image = inp . siblings ( "img" ) ;
113
+ assert . ok ( image . length === 0 , "Focus - image absent" ) ;
135
114
136
- var inp = testHelper . initNewInput ( ) ,
137
- dp = $ ( "#ui-datepicker-div" ) ;
115
+ testHelper . onFocus ( inp , function ( ) {
116
+ assert . ok ( dp . is ( ":visible" ) , "Focus - rendered on focus" ) ;
117
+ inp . simulate ( "keydown" , { keyCode : $ . ui . keyCode . ESCAPE } ) ;
118
+ assert . ok ( ! dp . is ( ":visible" ) , "Focus - hidden on exit" ) ;
119
+ step1 ( ) ;
120
+ } ) ;
121
+ }
138
122
139
- testHelper . onFocus ( inp , function ( ) {
140
- assert . ok ( dp . is ( ":visible" ) , "Focus - rendered on focus" ) ;
141
- body . simulate ( "mousedown" , { } ) ;
142
- assert . ok ( ! dp . is ( ":visible" ) , "Focus - hidden on external click" ) ;
143
- inp . datepicker ( "hide" ) . datepicker ( "destroy" ) ;
123
+ function step1 ( ) {
144
124
145
- step2 ( ) ;
146
- } ) ;
147
- }
125
+ var inp = testHelper . initNewInput ( ) ,
126
+ dp = $ ( "#ui-datepicker-div" ) ;
148
127
149
- function step2 ( ) {
150
- var inp = testHelper . initNewInput ( {
151
- showOn : "button" ,
152
- buttonText : "Popup"
153
- } ) ,
154
- dp = $ ( "#ui-datepicker-div" ) ;
155
-
156
- assert . ok ( ! dp . is ( ":visible" ) , "Button - initially hidden" ) ;
157
- button = inp . siblings ( "button" ) ;
158
- image = inp . siblings ( "img" ) ;
159
- assert . ok ( button . length === 1 , "Button - button present" ) ;
160
- assert . ok ( image . length === 0 , "Button - image absent" ) ;
161
- assert . equal ( button . text ( ) , "Popup" , "Button - button text" ) ;
162
-
163
- testHelper . onFocus ( inp , function ( ) {
164
- assert . ok ( ! dp . is ( ":visible" ) , "Button - not rendered on focus" ) ;
165
- button . trigger ( "click" ) ;
166
- assert . ok ( dp . is ( ":visible" ) , "Button - rendered on button click" ) ;
167
- button . trigger ( "click" ) ;
168
- assert . ok ( ! dp . is ( ":visible" ) , "Button - hidden on second button click" ) ;
169
- inp . datepicker ( "hide" ) . datepicker ( "destroy" ) ;
170
-
171
- step3 ( ) ;
172
- } ) ;
173
- }
128
+ testHelper . onFocus ( inp , function ( ) {
129
+ assert . ok ( dp . is ( ":visible" ) , "Focus - rendered on focus" ) ;
130
+ body . simulate ( "mousedown" , { } ) ;
131
+ assert . ok ( ! dp . is ( ":visible" ) , "Focus - hidden on external click" ) ;
132
+ inp . datepicker ( "hide" ) . datepicker ( "destroy" ) ;
174
133
175
- function step3 ( ) {
176
- var inp = testHelper . initNewInput ( {
177
- showOn : "button" ,
178
- buttonImageOnly : true ,
179
- buttonImage : "images/calendar.gif" ,
180
- buttonText : "Cal"
181
- } ) ,
182
- dp = $ ( "#ui-datepicker-div" ) ;
183
-
184
- assert . ok ( ! dp . is ( ":visible" ) , "Image button - initially hidden" ) ;
185
- button = inp . siblings ( "button" ) ;
186
- assert . ok ( button . length === 0 , "Image button - button absent" ) ;
187
- image = inp . siblings ( "img" ) ;
188
- assert . ok ( image . length === 1 , "Image button - image present" ) ;
189
- assert . ok ( / i m a g e s \/ c a l e n d a r \. g i f $ / . test ( image . attr ( "src" ) ) , "Image button - image source" ) ;
190
- assert . equal ( image . attr ( "title" ) , "Cal" , "Image button - image text" ) ;
191
-
192
- testHelper . onFocus ( inp , function ( ) {
193
- assert . ok ( ! dp . is ( ":visible" ) , "Image button - not rendered on focus" ) ;
194
- image . trigger ( "click" ) ;
195
- assert . ok ( dp . is ( ":visible" ) , "Image button - rendered on image click" ) ;
196
- image . trigger ( "click" ) ;
197
- assert . ok ( ! dp . is ( ":visible" ) , "Image button - hidden on second image click" ) ;
198
- inp . datepicker ( "hide" ) . datepicker ( "destroy" ) ;
199
-
200
- step4 ( ) ;
201
- } ) ;
202
- }
134
+ step2 ( ) ;
135
+ } ) ;
136
+ }
203
137
204
- function step4 ( ) {
205
- var inp = testHelper . initNewInput ( {
206
- showOn : "both" ,
207
- buttonImage : "images/calendar.gif"
208
- } ) ,
209
- dp = $ ( "#ui-datepicker-div" ) ;
210
-
211
- assert . ok ( ! dp . is ( ":visible" ) , "Both - initially hidden" ) ;
212
- button = inp . siblings ( "button" ) ;
213
- assert . ok ( button . length === 1 , "Both - button present" ) ;
214
- image = inp . siblings ( "img" ) ;
215
- assert . ok ( image . length === 0 , "Both - image absent" ) ;
216
- image = button . children ( "img" ) ;
217
- assert . ok ( image . length === 1 , "Both - button image present" ) ;
218
-
219
- // TODO: This test occasionally fails to focus in IE8 in BrowserStack
220
- if ( ! isOldIE ) {
221
- testHelper . onFocus ( inp , function ( ) {
222
- assert . ok ( dp . is ( ":visible" ) , "Both - rendered on focus" ) ;
223
- body . simulate ( "mousedown" , { } ) ;
224
- assert . ok ( ! dp . is ( ":visible" ) , "Both - hidden on external click" ) ;
225
- button . trigger ( "click" ) ;
226
- assert . ok ( dp . is ( ":visible" ) , "Both - rendered on button click" ) ;
227
- button . trigger ( "click" ) ;
228
- assert . ok ( ! dp . is ( ":visible" ) , "Both - hidden on second button click" ) ;
229
- inp . datepicker ( "hide" ) . datepicker ( "destroy" ) ;
230
-
231
- ready ( ) ;
232
- } ) ;
233
- } else {
234
- ready ( ) ;
235
- }
236
- }
138
+ function step2 ( ) {
139
+ var inp = testHelper . initNewInput ( {
140
+ showOn : "button" ,
141
+ buttonText : "Popup"
142
+ } ) ,
143
+ dp = $ ( "#ui-datepicker-div" ) ;
144
+
145
+ assert . ok ( ! dp . is ( ":visible" ) , "Button - initially hidden" ) ;
146
+ button = inp . siblings ( "button" ) ;
147
+ image = inp . siblings ( "img" ) ;
148
+ assert . ok ( button . length === 1 , "Button - button present" ) ;
149
+ assert . ok ( image . length === 0 , "Button - image absent" ) ;
150
+ assert . equal ( button . text ( ) , "Popup" , "Button - button text" ) ;
151
+
152
+ testHelper . onFocus ( inp , function ( ) {
153
+ assert . ok ( ! dp . is ( ":visible" ) , "Button - not rendered on focus" ) ;
154
+ button . trigger ( "click" ) ;
155
+ assert . ok ( dp . is ( ":visible" ) , "Button - rendered on button click" ) ;
156
+ button . trigger ( "click" ) ;
157
+ assert . ok ( ! dp . is ( ":visible" ) , "Button - hidden on second button click" ) ;
158
+ inp . datepicker ( "hide" ) . datepicker ( "destroy" ) ;
159
+
160
+ step3 ( ) ;
161
+ } ) ;
162
+ }
237
163
238
- step0 ( ) ;
239
- } ) ;
240
- } ) ( ) ;
164
+ function step3 ( ) {
165
+ var inp = testHelper . initNewInput ( {
166
+ showOn : "button" ,
167
+ buttonImageOnly : true ,
168
+ buttonImage : "images/calendar.gif" ,
169
+ buttonText : "Cal"
170
+ } ) ,
171
+ dp = $ ( "#ui-datepicker-div" ) ;
172
+
173
+ assert . ok ( ! dp . is ( ":visible" ) , "Image button - initially hidden" ) ;
174
+ button = inp . siblings ( "button" ) ;
175
+ assert . ok ( button . length === 0 , "Image button - button absent" ) ;
176
+ image = inp . siblings ( "img" ) ;
177
+ assert . ok ( image . length === 1 , "Image button - image present" ) ;
178
+ assert . ok ( / i m a g e s \/ c a l e n d a r \. g i f $ / . test ( image . attr ( "src" ) ) , "Image button - image source" ) ;
179
+ assert . equal ( image . attr ( "title" ) , "Cal" , "Image button - image text" ) ;
180
+
181
+ testHelper . onFocus ( inp , function ( ) {
182
+ assert . ok ( ! dp . is ( ":visible" ) , "Image button - not rendered on focus" ) ;
183
+ image . trigger ( "click" ) ;
184
+ assert . ok ( dp . is ( ":visible" ) , "Image button - rendered on image click" ) ;
185
+ image . trigger ( "click" ) ;
186
+ assert . ok ( ! dp . is ( ":visible" ) , "Image button - hidden on second image click" ) ;
187
+ inp . datepicker ( "hide" ) . datepicker ( "destroy" ) ;
188
+
189
+ step4 ( ) ;
190
+ } ) ;
191
+ }
192
+
193
+ function step4 ( ) {
194
+ var inp = testHelper . initNewInput ( {
195
+ showOn : "both" ,
196
+ buttonImage : "images/calendar.gif"
197
+ } ) ,
198
+ dp = $ ( "#ui-datepicker-div" ) ;
199
+
200
+ assert . ok ( ! dp . is ( ":visible" ) , "Both - initially hidden" ) ;
201
+ button = inp . siblings ( "button" ) ;
202
+ assert . ok ( button . length === 1 , "Both - button present" ) ;
203
+ image = inp . siblings ( "img" ) ;
204
+ assert . ok ( image . length === 0 , "Both - image absent" ) ;
205
+ image = button . children ( "img" ) ;
206
+ assert . ok ( image . length === 1 , "Both - button image present" ) ;
207
+
208
+ testHelper . onFocus ( inp , function ( ) {
209
+ assert . ok ( dp . is ( ":visible" ) , "Both - rendered on focus" ) ;
210
+ body . simulate ( "mousedown" , { } ) ;
211
+ assert . ok ( ! dp . is ( ":visible" ) , "Both - hidden on external click" ) ;
212
+ button . trigger ( "click" ) ;
213
+ assert . ok ( dp . is ( ":visible" ) , "Both - rendered on button click" ) ;
214
+ button . trigger ( "click" ) ;
215
+ assert . ok ( ! dp . is ( ":visible" ) , "Both - hidden on second button click" ) ;
216
+ inp . datepicker ( "hide" ) . datepicker ( "destroy" ) ;
217
+
218
+ ready ( ) ;
219
+ } ) ;
220
+ }
221
+
222
+ step0 ( ) ;
223
+ } ) ;
241
224
242
225
QUnit . test ( "otherMonths" , function ( assert ) {
243
226
assert . expect ( 8 ) ;
0 commit comments