@@ -87,6 +87,10 @@ describe('md-calendar', function() {
87
87
} ) ;
88
88
}
89
89
90
+ function getFocusedDateElement ( ) {
91
+ return element . querySelector ( '.md-focus' ) ;
92
+ }
93
+
90
94
beforeEach ( module ( 'material.components.calendar' , 'ngAnimateMock' ) ) ;
91
95
92
96
beforeEach ( inject ( function ( $injector ) {
@@ -221,48 +225,48 @@ describe('md-calendar', function() {
221
225
selectedDate . focus ( ) ;
222
226
223
227
dispatchKeyEvent ( keyCodes . LEFT_ARROW ) ;
224
- expect ( document . activeElement . textContent ) . toBe ( '10' ) ;
225
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Feb 2014' ) ;
228
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '10' ) ;
229
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Feb 2014' ) ;
226
230
227
231
dispatchKeyEvent ( keyCodes . UP_ARROW ) ;
228
- expect ( document . activeElement . textContent ) . toBe ( '3' ) ;
229
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Feb 2014' ) ;
232
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '3' ) ;
233
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Feb 2014' ) ;
230
234
231
235
dispatchKeyEvent ( keyCodes . RIGHT_ARROW ) ;
232
- expect ( document . activeElement . textContent ) . toBe ( '4' ) ;
233
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Feb 2014' ) ;
236
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '4' ) ;
237
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Feb 2014' ) ;
234
238
235
239
dispatchKeyEvent ( keyCodes . DOWN_ARROW ) ;
236
- expect ( document . activeElement . textContent ) . toBe ( '11' ) ;
237
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Feb 2014' ) ;
240
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '11' ) ;
241
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Feb 2014' ) ;
238
242
239
243
dispatchKeyEvent ( keyCodes . HOME ) ;
240
- expect ( document . activeElement . textContent ) . toBe ( '1' ) ;
241
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Feb 2014' ) ;
244
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '1' ) ;
245
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Feb 2014' ) ;
242
246
243
247
dispatchKeyEvent ( keyCodes . END ) ;
244
- expect ( document . activeElement . textContent ) . toBe ( '28' ) ;
245
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Feb 2014' ) ;
248
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '28' ) ;
249
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Feb 2014' ) ;
246
250
247
251
dispatchKeyEvent ( keyCodes . RIGHT_ARROW ) ;
248
- expect ( document . activeElement . textContent ) . toBe ( '1' ) ;
249
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Mar 2014' ) ;
252
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '1' ) ;
253
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Mar 2014' ) ;
250
254
251
255
dispatchKeyEvent ( keyCodes . PAGE_UP ) ;
252
- expect ( document . activeElement . textContent ) . toBe ( '1' ) ;
253
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Feb 2014' ) ;
256
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '1' ) ;
257
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Feb 2014' ) ;
254
258
255
259
dispatchKeyEvent ( keyCodes . PAGE_DOWN ) ;
256
- expect ( document . activeElement . textContent ) . toBe ( '1' ) ;
257
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Mar 2014' ) ;
260
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '1' ) ;
261
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Mar 2014' ) ;
258
262
259
263
dispatchKeyEvent ( keyCodes . UP_ARROW , { meta : true } ) ;
260
- expect ( document . activeElement . textContent ) . toBe ( '1' ) ;
261
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Feb 2014' ) ;
264
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '1' ) ;
265
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Feb 2014' ) ;
262
266
263
267
dispatchKeyEvent ( keyCodes . DOWN_ARROW , { meta : true } ) ;
264
- expect ( document . activeElement . textContent ) . toBe ( '1' ) ;
265
- expect ( getMonthLabelForDateCell ( document . activeElement ) ) . toBe ( 'Mar 2014' ) ;
268
+ expect ( getFocusedDateElement ( ) . textContent ) . toBe ( '1' ) ;
269
+ expect ( getMonthLabelForDateCell ( getFocusedDateElement ( ) ) ) . toBe ( 'Mar 2014' ) ;
266
270
267
271
dispatchKeyEvent ( keyCodes . ENTER ) ;
268
272
applyDateChange ( ) ;
0 commit comments