Skip to content

Commit c84ea01

Browse files
author
John Doe
committed
refactor: add test
1 parent 896fb75 commit c84ea01

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/utils/src/lib/exit-process.int.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)