@@ -4,7 +4,7 @@ import { SIGNAL_EXIT_CODES, installExitHandlers } from './exit-process.js';
44
55describe ( 'installExitHandlers' , ( ) => {
66 const onError = vi . fn ( ) ;
7- const onClose = vi . fn ( ) ;
7+ const onExit = vi . fn ( ) ;
88 const processOnSpy = vi . spyOn ( process , 'on' ) ;
99 const processExitSpy = vi . spyOn ( process , 'exit' ) . mockImplementation ( vi . fn ( ) ) ;
1010
@@ -26,7 +26,7 @@ describe('installExitHandlers', () => {
2626 } ) ;
2727
2828 it ( 'should install event listeners for all expected events' , ( ) => {
29- expect ( ( ) => installExitHandlers ( { onError, onClose } ) ) . not . toThrow ( ) ;
29+ expect ( ( ) => installExitHandlers ( { onError, onExit } ) ) . not . toThrow ( ) ;
3030
3131 expect ( processOnSpy ) . toHaveBeenCalledWith (
3232 'uncaughtException' ,
@@ -51,7 +51,7 @@ describe('installExitHandlers', () => {
5151
5252 expect ( onError ) . toHaveBeenCalledWith ( testError , 'uncaughtException' ) ;
5353 expect ( onError ) . toHaveBeenCalledTimes ( 1 ) ;
54- expect ( onClose ) . not . toHaveBeenCalled ( ) ;
54+ expect ( onExit ) . not . toHaveBeenCalled ( ) ;
5555 } ) ;
5656
5757 it ( 'should call onError with reason and kind for unhandledRejection' , ( ) => {
@@ -63,55 +63,55 @@ describe('installExitHandlers', () => {
6363
6464 expect ( onError ) . toHaveBeenCalledWith ( testReason , 'unhandledRejection' ) ;
6565 expect ( onError ) . toHaveBeenCalledTimes ( 1 ) ;
66- expect ( onClose ) . not . toHaveBeenCalled ( ) ;
66+ expect ( onExit ) . not . toHaveBeenCalled ( ) ;
6767 } ) ;
6868
69- it ( 'should call onClose and exit with code 0 for SIGINT' , ( ) => {
70- expect ( ( ) => installExitHandlers ( { onClose } ) ) . not . toThrow ( ) ;
69+ it ( 'should call onExit and exit with code 0 for SIGINT' , ( ) => {
70+ expect ( ( ) => installExitHandlers ( { onExit } ) ) . not . toThrow ( ) ;
7171
7272 ( process as any ) . emit ( 'SIGINT' ) ;
7373
74- expect ( onClose ) . toHaveBeenCalledTimes ( 1 ) ;
75- expect ( onClose ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGINT , {
74+ expect ( onExit ) . toHaveBeenCalledTimes ( 1 ) ;
75+ expect ( onExit ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGINT , {
7676 kind : 'signal' ,
7777 signal : 'SIGINT' ,
7878 } ) ;
7979 expect ( onError ) . not . toHaveBeenCalled ( ) ;
8080 } ) ;
8181
82- it ( 'should call onClose and exit with code 0 for SIGTERM' , ( ) => {
83- expect ( ( ) => installExitHandlers ( { onClose } ) ) . not . toThrow ( ) ;
82+ it ( 'should call onExit and exit with code 0 for SIGTERM' , ( ) => {
83+ expect ( ( ) => installExitHandlers ( { onExit } ) ) . not . toThrow ( ) ;
8484
8585 ( process as any ) . emit ( 'SIGTERM' ) ;
8686
87- expect ( onClose ) . toHaveBeenCalledTimes ( 1 ) ;
88- expect ( onClose ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGTERM , {
87+ expect ( onExit ) . toHaveBeenCalledTimes ( 1 ) ;
88+ expect ( onExit ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGTERM , {
8989 kind : 'signal' ,
9090 signal : 'SIGTERM' ,
9191 } ) ;
9292 expect ( onError ) . not . toHaveBeenCalled ( ) ;
9393 } ) ;
9494
95- it ( 'should call onClose and exit with code 0 for SIGQUIT' , ( ) => {
96- expect ( ( ) => installExitHandlers ( { onClose } ) ) . not . toThrow ( ) ;
95+ it ( 'should call onExit and exit with code 0 for SIGQUIT' , ( ) => {
96+ expect ( ( ) => installExitHandlers ( { onExit } ) ) . not . toThrow ( ) ;
9797
9898 ( process as any ) . emit ( 'SIGQUIT' ) ;
9999
100- expect ( onClose ) . toHaveBeenCalledTimes ( 1 ) ;
101- expect ( onClose ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGQUIT , {
100+ expect ( onExit ) . toHaveBeenCalledTimes ( 1 ) ;
101+ expect ( onExit ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGQUIT , {
102102 kind : 'signal' ,
103103 signal : 'SIGQUIT' ,
104104 } ) ;
105105 expect ( onError ) . not . toHaveBeenCalled ( ) ;
106106 } ) ;
107107
108- it ( 'should call onClose for normal exit' , ( ) => {
109- expect ( ( ) => installExitHandlers ( { onClose } ) ) . not . toThrow ( ) ;
108+ it ( 'should call onExit for normal exit' , ( ) => {
109+ expect ( ( ) => installExitHandlers ( { onExit } ) ) . not . toThrow ( ) ;
110110
111111 ( process as any ) . emit ( 'exit' ) ;
112112
113- expect ( onClose ) . toHaveBeenCalledTimes ( 1 ) ;
114- expect ( onClose ) . toHaveBeenCalledWith ( undefined , { kind : 'exit' } ) ;
113+ expect ( onExit ) . toHaveBeenCalledTimes ( 1 ) ;
114+ expect ( onExit ) . toHaveBeenCalledWith ( undefined , { kind : 'exit' } ) ;
115115 expect ( onError ) . not . toHaveBeenCalled ( ) ;
116116 expect ( processExitSpy ) . not . toHaveBeenCalled ( ) ;
117117 } ) ;
0 commit comments