File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -220,4 +220,29 @@ describe('elements/content-sidebar/BoxAISidebar', () => {
220220
221221 expect ( screen . queryByTestId ( 'content-answers-modal' ) ) . not . toBeInTheDocument ( ) ;
222222 } ) ;
223+
224+ describe ( 'BoxAISidebar handleKeyPress' , ( ) => {
225+
226+ test ( 'should prevent default behavior and stop propagation for ArrowLeft and ArrowRight keys' , async ( ) => {
227+ await renderComponent ( ) ;
228+
229+ const eventLeft = new KeyboardEvent ( 'keydown' , { key : 'ArrowLeft' } ) ;
230+ const preventDefaultSpy = jest . spyOn ( eventLeft , 'preventDefault' ) ;
231+ const stopPropagationSpy = jest . spyOn ( eventLeft , 'stopPropagation' ) ;
232+
233+ document . dispatchEvent ( eventLeft ) ;
234+
235+ expect ( preventDefaultSpy ) . toHaveBeenCalled ( ) ;
236+ expect ( stopPropagationSpy ) . toHaveBeenCalled ( ) ;
237+
238+ const eventRight = new KeyboardEvent ( 'keydown' , { key : 'ArrowRight' } ) ;
239+ const preventDefaultSpyRight = jest . spyOn ( eventRight , 'preventDefault' ) ;
240+ const stopPropagationSpyRight = jest . spyOn ( eventRight , 'stopPropagation' ) ;
241+
242+ document . dispatchEvent ( eventRight ) ;
243+
244+ expect ( preventDefaultSpyRight ) . toHaveBeenCalled ( ) ;
245+ expect ( stopPropagationSpyRight ) . toHaveBeenCalled ( ) ;
246+ } ) ;
247+ } ) ;
223248} ) ;
You can’t perform that action at this time.
0 commit comments