Skip to content

Commit 5ffcabc

Browse files
committed
test: add spy on process exit
1 parent 7975065 commit 5ffcabc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/utils.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ import {
55
describe,
66
} from 'vitest';
77

8-
import { graceful } from '../lib/utils';
8+
import { graceful } from '../lib/utils.js';
9+
import { EMPTY_STRING_INPUT } from './seeds.js';
910

1011
describe('Graceful', () => {
1112
test('Execute graceful', () => {
1213
const fn = vi.fn();
1314
graceful(fn);
1415
expect(fn).toBeCalled();
1516
});
17+
18+
test('Trigger graceful exit', () => {
19+
const processExit = vi.spyOn(process, 'exit').mockImplementation(() => {});
20+
graceful(EMPTY_STRING_INPUT);
21+
expect(processExit).toHaveBeenCalled();
22+
});
1623
});

0 commit comments

Comments
 (0)