@@ -98,33 +98,33 @@ describe('createSwitchifyTray', () => {
9898 expect ( callbacks . quit ) . not . toHaveBeenCalled ( ) ;
9999 } ) ;
100100
101- it ( 'opens the context menu on Windows right-click ' , ( ) => {
101+ it ( 'attaches the context menu on Windows' , ( ) => {
102102 const callbacks = createCallbacks ( ) ;
103103 createSwitchifyTray ( {
104104 ...callbacks ,
105105 getStatus : ( ) => status ( )
106106 } ) ;
107107
108- tray ( ) . emit ( 'right-click' ) ;
109-
110- expect ( tray ( ) . popUpContextMenu ) . toHaveBeenCalledTimes ( 1 ) ;
111- expect ( tray ( ) . popUpContextMenu ) . toHaveBeenCalledWith ( lastMenu ( ) ) ;
112- expect ( callbacks . showWindow ) . not . toHaveBeenCalled ( ) ;
108+ expect ( tray ( ) . setContextMenu ) . toHaveBeenCalledTimes ( 1 ) ;
109+ expect ( tray ( ) . setContextMenu ) . toHaveBeenCalledWith ( lastMenu ( ) ) ;
110+ expect ( tray ( ) . popUpContextMenu ) . not . toHaveBeenCalled ( ) ;
111+ expect ( tray ( ) . handlers . has ( 'right-click' ) ) . toBe ( false ) ;
113112 } ) ;
114113
115- it ( 'refreshes the right-click menu with the latest status' , ( ) => {
114+ it ( 'refreshes the context menu with the latest status on update ' , ( ) => {
116115 const callbacks = createCallbacks ( ) ;
117116 let connectedClientCount = 0 ;
118- createSwitchifyTray ( {
117+ const switchifyTray = createSwitchifyTray ( {
119118 ...callbacks ,
120119 getStatus : ( ) => status ( { connectedClientCount } )
121120 } ) ;
122121
123122 connectedClientCount = 1 ;
124- tray ( ) . emit ( 'right-click' ) ;
123+ switchifyTray . update ( ) ;
125124
126125 const disconnectItem = lastMenu ( ) . template . find ( ( item ) => item . label === 'Disconnect device' ) ;
127126 expect ( disconnectItem ?. enabled ) . toBe ( true ) ;
127+ expect ( tray ( ) . setContextMenu ) . toHaveBeenLastCalledWith ( lastMenu ( ) ) ;
128128 } ) ;
129129
130130 it ( 'refreshes the tooltip on update' , ( ) => {
0 commit comments