@@ -513,33 +513,40 @@ describe('Tab', () => {
513513 '<div class="nav">' ,
514514 ' <span id="tab1" class="nav-link" data-bs-toggle="tab"></span>' ,
515515 ' <span id="tab2" class="nav-link" data-bs-toggle="tab"></span>' ,
516+ ' <span id="tab3" class="nav-link" data-bs-toggle="tab"></span>' ,
516517 '</div>'
517518 ] . join ( '' )
518519
519- const tabEl = fixtureEl . querySelector ( '#tab1' )
520+ const tabEl1 = fixtureEl . querySelector ( '#tab1' )
520521 const tabEl2 = fixtureEl . querySelector ( '#tab2' )
521- const tab = new Tab ( tabEl )
522+ const tabEl3 = fixtureEl . querySelector ( '#tab3' )
523+ const tab1 = new Tab ( tabEl1 )
522524 const tab2 = new Tab ( tabEl2 )
523- const spyShow1 = spyOn ( tab , 'show' ) . and . callThrough ( )
525+ const tab3 = new Tab ( tabEl3 )
526+ const spyShow1 = spyOn ( tab1 , 'show' ) . and . callThrough ( )
524527 const spyShow2 = spyOn ( tab2 , 'show' ) . and . callThrough ( )
528+ const spyShow3 = spyOn ( tab3 , 'show' ) . and . callThrough ( )
525529
526530 const spyStop = spyOn ( Event . prototype , 'stopPropagation' ) . and . callThrough ( )
527531 const spyPrevent = spyOn ( Event . prototype , 'preventDefault' ) . and . callThrough ( )
528532
529533 let keydown = createEvent ( 'keydown' )
530534 keydown . key = 'ArrowRight'
531535
532- tabEl . dispatchEvent ( keydown )
536+ tabEl1 . dispatchEvent ( keydown )
533537 expect ( spyShow2 ) . toHaveBeenCalled ( )
534538
535539 keydown = createEvent ( 'keydown' )
536540 keydown . key = 'ArrowDown'
537541
538542 tabEl2 . dispatchEvent ( keydown )
543+ expect ( spyShow3 ) . toHaveBeenCalled ( )
544+
545+ tabEl3 . dispatchEvent ( keydown )
539546 expect ( spyShow1 ) . toHaveBeenCalled ( )
540547
541- expect ( spyStop ) . toHaveBeenCalledTimes ( 2 )
542- expect ( spyPrevent ) . toHaveBeenCalledTimes ( 2 )
548+ expect ( spyStop ) . toHaveBeenCalledTimes ( 3 )
549+ expect ( spyPrevent ) . toHaveBeenCalledTimes ( 3 )
543550 } )
544551
545552 it ( 'if keydown event is left arrow, handle it' , ( ) => {
0 commit comments