@@ -25,7 +25,7 @@ describe('subscribeProcessExit', () => {
2525 } ) ;
2626
2727 it ( 'should install event listeners for all expected events' , ( ) => {
28- expect ( ( ) => subscribeProcessExit ( { onError, onExit } ) ) . not . toThrow ( ) ;
28+ expect ( ( ) => subscribeProcessExit ( { onError, onExit } ) ) . not . toThrowError ( ) ;
2929
3030 expect ( processOnSpy ) . toHaveBeenCalledWith (
3131 'uncaughtException' ,
@@ -42,86 +42,91 @@ describe('subscribeProcessExit', () => {
4242 } ) ;
4343
4444 it ( 'should call onError with error and kind for uncaughtException' , ( ) => {
45- expect ( ( ) => subscribeProcessExit ( { onError } ) ) . not . toThrow ( ) ;
45+ expect ( ( ) => subscribeProcessExit ( { onError } ) ) . not . toThrowError ( ) ;
4646
4747 const testError = new Error ( 'Test uncaught exception' ) ;
4848
4949 ( process as any ) . emit ( 'uncaughtException' , testError ) ;
5050
51- expect ( onError ) . toHaveBeenCalledWith ( testError , 'uncaughtException' ) ;
52- expect ( onError ) . toHaveBeenCalledOnce ( ) ;
51+ expect ( onError ) . toHaveBeenCalledExactlyOnceWith (
52+ testError ,
53+ 'uncaughtException' ,
54+ ) ;
5355 expect ( onExit ) . not . toHaveBeenCalled ( ) ;
5456 } ) ;
5557
5658 it ( 'should call onError with reason and kind for unhandledRejection' , ( ) => {
57- expect ( ( ) => subscribeProcessExit ( { onError } ) ) . not . toThrow ( ) ;
59+ expect ( ( ) => subscribeProcessExit ( { onError } ) ) . not . toThrowError ( ) ;
5860
5961 const testReason = 'Test unhandled rejection' ;
6062
6163 ( process as any ) . emit ( 'unhandledRejection' , testReason ) ;
6264
63- expect ( onError ) . toHaveBeenCalledWith ( testReason , 'unhandledRejection' ) ;
64- expect ( onError ) . toHaveBeenCalledOnce ( ) ;
65+ expect ( onError ) . toHaveBeenCalledExactlyOnceWith (
66+ testReason ,
67+ 'unhandledRejection' ,
68+ ) ;
6569 expect ( onExit ) . not . toHaveBeenCalled ( ) ;
6670 } ) ;
6771
6872 it ( 'should call onExit and exit with code 0 for SIGINT' , ( ) => {
69- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
73+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
7074
7175 ( process as any ) . emit ( 'SIGINT' ) ;
7276
73- expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
74- expect ( onExit ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGINT , {
77+ expect ( onExit ) . toHaveBeenCalledExactlyOnceWith ( SIGNAL_EXIT_CODES ( ) . SIGINT , {
7578 kind : 'signal' ,
7679 signal : 'SIGINT' ,
7780 } ) ;
7881 expect ( onError ) . not . toHaveBeenCalled ( ) ;
7982 } ) ;
8083
8184 it ( 'should call onExit and exit with code 0 for SIGTERM' , ( ) => {
82- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
85+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
8386
8487 ( process as any ) . emit ( 'SIGTERM' ) ;
8588
86- expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
87- expect ( onExit ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGTERM , {
88- kind : 'signal' ,
89- signal : 'SIGTERM' ,
90- } ) ;
89+ expect ( onExit ) . toHaveBeenCalledExactlyOnceWith (
90+ SIGNAL_EXIT_CODES ( ) . SIGTERM ,
91+ {
92+ kind : 'signal' ,
93+ signal : 'SIGTERM' ,
94+ } ,
95+ ) ;
9196 expect ( onError ) . not . toHaveBeenCalled ( ) ;
9297 } ) ;
9398
9499 it ( 'should call onExit and exit with code 0 for SIGQUIT' , ( ) => {
95- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
100+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
96101
97102 ( process as any ) . emit ( 'SIGQUIT' ) ;
98103
99- expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
100- expect ( onExit ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGQUIT , {
101- kind : 'signal' ,
102- signal : 'SIGQUIT' ,
103- } ) ;
104+ expect ( onExit ) . toHaveBeenCalledExactlyOnceWith (
105+ SIGNAL_EXIT_CODES ( ) . SIGQUIT ,
106+ {
107+ kind : 'signal' ,
108+ signal : 'SIGQUIT' ,
109+ } ,
110+ ) ;
104111 expect ( onError ) . not . toHaveBeenCalled ( ) ;
105112 } ) ;
106113
107114 it ( 'should call onExit for successful process termination with exit code 0' , ( ) => {
108- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
115+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
109116
110117 ( process as any ) . emit ( 'exit' , 0 ) ;
111118
112- expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
113- expect ( onExit ) . toHaveBeenCalledWith ( 0 , { kind : 'exit' } ) ;
119+ expect ( onExit ) . toHaveBeenCalledExactlyOnceWith ( 0 , { kind : 'exit' } ) ;
114120 expect ( onError ) . not . toHaveBeenCalled ( ) ;
115121 expect ( processExitSpy ) . not . toHaveBeenCalled ( ) ;
116122 } ) ;
117123
118124 it ( 'should call onExit for failed process termination with exit code 1' , ( ) => {
119- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
125+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
120126
121127 ( process as any ) . emit ( 'exit' , 1 ) ;
122128
123- expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
124- expect ( onExit ) . toHaveBeenCalledWith ( 1 , { kind : 'exit' } ) ;
129+ expect ( onExit ) . toHaveBeenCalledExactlyOnceWith ( 1 , { kind : 'exit' } ) ;
125130 expect ( onError ) . not . toHaveBeenCalled ( ) ;
126131 expect ( processExitSpy ) . not . toHaveBeenCalled ( ) ;
127132 } ) ;
0 commit comments