File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -105,13 +105,24 @@ describe('installExitHandlers', () => {
105105 expect ( onError ) . not . toHaveBeenCalled ( ) ;
106106 } ) ;
107107
108- it ( 'should call onExit for normal exit' , ( ) => {
108+ it ( 'should call onExit for successful process termination with exit code 0 ' , ( ) => {
109109 expect ( ( ) => installExitHandlers ( { onExit } ) ) . not . toThrow ( ) ;
110110
111- ( process as any ) . emit ( 'exit' ) ;
111+ ( process as any ) . emit ( 'exit' , 0 ) ;
112112
113113 expect ( onExit ) . toHaveBeenCalledTimes ( 1 ) ;
114- expect ( onExit ) . toHaveBeenCalledWith ( undefined , { kind : 'exit' } ) ;
114+ expect ( onExit ) . toHaveBeenCalledWith ( 0 , { kind : 'exit' } ) ;
115+ expect ( onError ) . not . toHaveBeenCalled ( ) ;
116+ expect ( processExitSpy ) . not . toHaveBeenCalled ( ) ;
117+ } ) ;
118+
119+ it ( 'should call onExit for failed process termination with exit code 1' , ( ) => {
120+ expect ( ( ) => installExitHandlers ( { onExit } ) ) . not . toThrow ( ) ;
121+
122+ ( process as any ) . emit ( 'exit' , 1 ) ;
123+
124+ expect ( onExit ) . toHaveBeenCalledTimes ( 1 ) ;
125+ expect ( onExit ) . toHaveBeenCalledWith ( 1 , { kind : 'exit' } ) ;
115126 expect ( onError ) . not . toHaveBeenCalled ( ) ;
116127 expect ( processExitSpy ) . not . toHaveBeenCalled ( ) ;
117128 } ) ;
You can’t perform that action at this time.
0 commit comments