@@ -202,11 +202,9 @@ describe( 'FocusCycler', () => {
202
202
203
203
describe ( 'focusFirst()' , ( ) => {
204
204
it ( 'focuses first focusable view' , ( ) => {
205
- const spy = sinon . spy ( focusables . get ( 1 ) , 'focus' ) ;
206
-
207
205
cycler . focusFirst ( ) ;
208
206
209
- sinon . assert . calledOnce ( spy ) ;
207
+ sinon . assert . calledOnce ( focusables . get ( 1 ) . focus ) ;
210
208
} ) ;
211
209
212
210
it ( 'does not throw when no focusable items' , ( ) => {
@@ -232,7 +230,6 @@ describe( 'FocusCycler', () => {
232
230
233
231
it ( 'ignores invisible items' , ( ) => {
234
232
const item = focusable ( ) ;
235
- const spy = sinon . spy ( item , 'focus' ) ;
236
233
237
234
focusables = new ViewCollection ( ) ;
238
235
focusables . add ( nonFocusable ( ) ) ;
@@ -242,17 +239,15 @@ describe( 'FocusCycler', () => {
242
239
cycler = new FocusCycler ( { focusables, focusTracker } ) ;
243
240
244
241
cycler . focusFirst ( ) ;
245
- sinon . assert . calledOnce ( spy ) ;
242
+ sinon . assert . calledOnce ( item . focus ) ;
246
243
} ) ;
247
244
} ) ;
248
245
249
246
describe ( 'focusLast()' , ( ) => {
250
247
it ( 'focuses last focusable view' , ( ) => {
251
- const spy = sinon . spy ( focusables . get ( 3 ) , 'focus' ) ;
252
-
253
248
cycler . focusLast ( ) ;
254
249
255
- sinon . assert . calledOnce ( spy ) ;
250
+ sinon . assert . calledOnce ( focusables . get ( 3 ) . focus ) ;
256
251
} ) ;
257
252
258
253
it ( 'does not throw when no focusable items' , ( ) => {
@@ -279,12 +274,10 @@ describe( 'FocusCycler', () => {
279
274
280
275
describe ( 'focusNext()' , ( ) => {
281
276
it ( 'focuses next focusable view' , ( ) => {
282
- const spy = sinon . spy ( focusables . get ( 3 ) , 'focus' ) ;
283
-
284
277
focusTracker . focusedElement = focusables . get ( 2 ) . element ;
285
278
cycler . focusNext ( ) ;
286
279
287
- sinon . assert . calledOnce ( spy ) ;
280
+ sinon . assert . calledOnce ( focusables . get ( 3 ) . focus ) ;
288
281
} ) ;
289
282
290
283
it ( 'does not throw when no focusable items' , ( ) => {
@@ -311,12 +304,10 @@ describe( 'FocusCycler', () => {
311
304
312
305
describe ( 'focusPrevious()' , ( ) => {
313
306
it ( 'focuses previous focusable view' , ( ) => {
314
- const spy = sinon . spy ( focusables . get ( 3 ) , 'focus' ) ;
315
-
316
307
focusTracker . focusedElement = focusables . get ( 1 ) . element ;
317
308
cycler . focusPrevious ( ) ;
318
309
319
- sinon . assert . calledOnce ( spy ) ;
310
+ sinon . assert . calledOnce ( focusables . get ( 3 ) . focus ) ;
320
311
} ) ;
321
312
322
313
it ( 'does not throw when no focusable items' , ( ) => {
@@ -422,7 +413,7 @@ function nonFocusable( isHidden ) {
422
413
function focusable ( isHidden ) {
423
414
const view = nonFocusable ( isHidden ) ;
424
415
425
- view . focus = ( ) => { } ;
416
+ view . focus = sinon . spy ( ) ;
426
417
427
418
return view ;
428
419
}
0 commit comments