11import { ipcRenderer , shell } from 'electron' ;
2+
3+ import { namespacedEvent } from '../../shared/events' ;
24import { mockSettings } from '../__mocks__/state-mocks' ;
35import type { Link } from '../types' ;
46import {
@@ -63,50 +65,60 @@ describe('renderer/utils/comms.ts', () => {
6365 it ( 'should get app version' , async ( ) => {
6466 await getAppVersion ( ) ;
6567 expect ( ipcRenderer . invoke ) . toHaveBeenCalledTimes ( 1 ) ;
66- expect ( ipcRenderer . invoke ) . toHaveBeenCalledWith ( 'gitify: version') ;
68+ expect ( ipcRenderer . invoke ) . toHaveBeenCalledWith ( namespacedEvent ( ' version') ) ;
6769 } ) ;
6870
6971 it ( 'should quit the app' , ( ) => {
7072 quitApp ( ) ;
7173 expect ( ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
72- expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'gitify: quit') ;
74+ expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( namespacedEvent ( ' quit') ) ;
7375 } ) ;
7476
7577 it ( 'should show the window' , ( ) => {
7678 showWindow ( ) ;
7779 expect ( ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
78- expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'gitify:window-show' ) ;
80+ expect ( ipcRenderer . send ) . toHaveBeenCalledWith (
81+ namespacedEvent ( 'window-show' ) ,
82+ ) ;
7983 } ) ;
8084
8185 it ( 'should hide the window' , ( ) => {
8286 hideWindow ( ) ;
8387 expect ( ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
84- expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'gitify:window-hide' ) ;
88+ expect ( ipcRenderer . send ) . toHaveBeenCalledWith (
89+ namespacedEvent ( 'window-hide' ) ,
90+ ) ;
8591 } ) ;
8692
8793 it ( 'should setAutoLaunch (true)' , ( ) => {
8894 setAutoLaunch ( true ) ;
8995
90- expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'gitify:update-auto-launch' , {
91- openAtLogin : true ,
92- openAsHidden : true ,
93- } ) ;
96+ expect ( ipcRenderer . send ) . toHaveBeenCalledWith (
97+ namespacedEvent ( 'update-auto-launch' ) ,
98+ {
99+ openAtLogin : true ,
100+ openAsHidden : true ,
101+ } ,
102+ ) ;
94103 } ) ;
95104
96105 it ( 'should setAutoLaunch (false)' , ( ) => {
97106 setAutoLaunch ( false ) ;
98107
99- expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'gitify:update-auto-launch' , {
100- openAsHidden : false ,
101- openAtLogin : false ,
102- } ) ;
108+ expect ( ipcRenderer . send ) . toHaveBeenCalledWith (
109+ namespacedEvent ( 'update-auto-launch' ) ,
110+ {
111+ openAsHidden : false ,
112+ openAtLogin : false ,
113+ } ,
114+ ) ;
103115 } ) ;
104116
105117 it ( 'should setAlternateIdleIcon' , ( ) => {
106118 setAlternateIdleIcon ( true ) ;
107119
108120 expect ( ipcRenderer . send ) . toHaveBeenCalledWith (
109- 'gitify: use-alternate-idle-icon',
121+ namespacedEvent ( ' use-alternate-idle-icon') ,
110122 true ,
111123 ) ;
112124 } ) ;
@@ -115,7 +127,7 @@ describe('renderer/utils/comms.ts', () => {
115127 setKeyboardShortcut ( true ) ;
116128 expect ( ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
117129 expect ( ipcRenderer . send ) . toHaveBeenCalledWith (
118- 'gitify: update-keyboard-shortcut',
130+ namespacedEvent ( ' update-keyboard-shortcut') ,
119131 {
120132 enabled : true ,
121133 keyboardShortcut : Constants . DEFAULT_KEYBOARD_SHORTCUT ,
@@ -127,7 +139,7 @@ describe('renderer/utils/comms.ts', () => {
127139 setKeyboardShortcut ( false ) ;
128140 expect ( ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
129141 expect ( ipcRenderer . send ) . toHaveBeenCalledWith (
130- 'gitify: update-keyboard-shortcut',
142+ namespacedEvent ( ' update-keyboard-shortcut') ,
131143 {
132144 enabled : false ,
133145 keyboardShortcut : Constants . DEFAULT_KEYBOARD_SHORTCUT ,
@@ -139,13 +151,15 @@ describe('renderer/utils/comms.ts', () => {
139151 const notificationsLength = 3 ;
140152 updateTrayIcon ( notificationsLength ) ;
141153 expect ( ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
142- expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'gitify:icon-active' ) ;
154+ expect ( ipcRenderer . send ) . toHaveBeenCalledWith (
155+ namespacedEvent ( 'icon-active' ) ,
156+ ) ;
143157 } ) ;
144158
145159 it ( 'should send mark the icons as idle' , ( ) => {
146160 const notificationsLength = 0 ;
147161 updateTrayIcon ( notificationsLength ) ;
148162 expect ( ipcRenderer . send ) . toHaveBeenCalledTimes ( 1 ) ;
149- expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'gitify: icon-idle') ;
163+ expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( namespacedEvent ( ' icon-idle') ) ;
150164 } ) ;
151165} ) ;
0 commit comments