@@ -44,6 +44,51 @@ describe('Browser Keyboard Shortcuts test suite', () => {
4444 } ) ;
4545 } ) ;
4646 describe ( 'Control modified events' , ( ) => {
47+ test ( 'ctrl+R, should send reload app event' , ( ) => {
48+ // Given
49+ browserKeyboardShortcuts . initKeyboardShortcuts ( ) ;
50+ // When
51+ globalThis . dispatchEvent ( new KeyboardEvent ( 'keyup' , { key : 'R' , ctrlKey : true } ) ) ;
52+ // Then
53+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
54+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledWith ( 'reload' ) ;
55+ } ) ;
56+ test ( 'ctrl+r (lowercase), should send reload app event' , ( ) => {
57+ // Given
58+ browserKeyboardShortcuts . initKeyboardShortcuts ( ) ;
59+ // When
60+ globalThis . dispatchEvent ( new KeyboardEvent ( 'keyup' , { key : 'r' , ctrlKey : true } ) ) ;
61+ // Then
62+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
63+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledWith ( 'reload' ) ;
64+ } ) ;
65+ test ( 'ctrl++ (zoom in), should send zoomIn event' , ( ) => {
66+ // Given
67+ browserKeyboardShortcuts . initKeyboardShortcuts ( ) ;
68+ // When
69+ globalThis . dispatchEvent ( new KeyboardEvent ( 'keyup' , { key : '+' , ctrlKey : true } ) ) ;
70+ // Then
71+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
72+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledWith ( 'zoomIn' ) ;
73+ } ) ;
74+ test ( 'ctrl+- (zoom out), should send zoomOut event' , ( ) => {
75+ // Given
76+ browserKeyboardShortcuts . initKeyboardShortcuts ( ) ;
77+ // When
78+ globalThis . dispatchEvent ( new KeyboardEvent ( 'keyup' , { key : '-' , ctrlKey : true } ) ) ;
79+ // Then
80+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
81+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledWith ( 'zoomOut' ) ;
82+ } ) ;
83+ test ( 'ctrl+0 (zoom reset), should send zoomReset event' , ( ) => {
84+ // Given
85+ browserKeyboardShortcuts . initKeyboardShortcuts ( ) ;
86+ // When
87+ globalThis . dispatchEvent ( new KeyboardEvent ( 'keyup' , { key : '0' , ctrlKey : true } ) ) ;
88+ // Then
89+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
90+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledWith ( 'zoomReset' ) ;
91+ } ) ;
4792 test ( 'ctrl+unrecognized_key, should NOT send any app event' , ( ) => {
4893 // Given
4994 browserKeyboardShortcuts . initKeyboardShortcuts ( ) ;
@@ -63,6 +108,15 @@ describe('Browser Keyboard Shortcuts test suite', () => {
63108 expect ( electron . ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
64109 expect ( electron . ipcRenderer . send ) . toHaveBeenCalledWith ( 'reload' ) ;
65110 } ) ;
111+ test ( 'cmd+r (lowercase), should send reload app event' , ( ) => {
112+ // Given
113+ browserKeyboardShortcuts . initKeyboardShortcuts ( ) ;
114+ // When
115+ globalThis . dispatchEvent ( new KeyboardEvent ( 'keyup' , { key : 'r' , metaKey : true } ) ) ;
116+ // Then
117+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
118+ expect ( electron . ipcRenderer . send ) . toHaveBeenCalledWith ( 'reload' ) ;
119+ } ) ;
66120 } ) ;
67121 describe ( 'Mouse wheel events' , ( ) => {
68122 test ( 'ctrl+scrollUp, should send zoomIn event' , ( ) => {
0 commit comments