@@ -32,7 +32,7 @@ it('returns commands that map SIGINT to exit code 0', () => {
32
32
33
33
const callback = jest . fn ( ) ;
34
34
newCommands [ 0 ] . close . subscribe ( callback ) ;
35
- process . emit ( 'SIGINT' ) ;
35
+ process . emit ( 'SIGINT' , 'SIGINT' ) ;
36
36
37
37
// A fake command's .kill() call won't trigger a close event automatically...
38
38
commands [ 0 ] . close . next ( createFakeCloseEvent ( { exitCode : 1 } ) ) ;
@@ -56,7 +56,7 @@ it('returns commands that keep non-SIGINT exit codes', () => {
56
56
describe . each ( [ 'SIGINT' , 'SIGTERM' , 'SIGHUP' ] ) ( 'on %s' , ( signal ) => {
57
57
it ( 'kills all commands' , ( ) => {
58
58
controller . handle ( commands ) ;
59
- process . emit ( signal ) ;
59
+ process . emit ( signal , signal ) ;
60
60
61
61
expect ( process . listenerCount ( signal ) ) . toBe ( 1 ) ;
62
62
expect ( commands [ 0 ] . kill ) . toHaveBeenCalledWith ( signal ) ;
@@ -65,8 +65,14 @@ describe.each(['SIGINT', 'SIGTERM', 'SIGHUP'])('on %s', (signal) => {
65
65
66
66
it ( 'sends abort signal' , ( ) => {
67
67
controller . handle ( commands ) ;
68
- process . emit ( signal ) ;
68
+ process . emit ( signal , signal ) ;
69
69
70
70
expect ( abortController . signal . aborted ) . toBe ( true ) ;
71
71
} ) ;
72
+
73
+ it ( 'removes event listener on finish' , ( ) => {
74
+ const { onFinish } = controller . handle ( commands ) ;
75
+ onFinish ( ) ;
76
+ expect ( process . listenerCount ( signal ) ) . toBe ( 0 ) ;
77
+ } ) ;
72
78
} ) ;
0 commit comments