Skip to content

Commit

Permalink
test: add spy on process exit
Browse files Browse the repository at this point in the history
  • Loading branch information
airscripts committed Jul 30, 2023
1 parent 7975065 commit 5ffcabc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ import {
describe,
} from 'vitest';

import { graceful } from '../lib/utils';
import { graceful } from '../lib/utils.js';
import { EMPTY_STRING_INPUT } from './seeds.js';

describe('Graceful', () => {
test('Execute graceful', () => {
const fn = vi.fn();
graceful(fn);
expect(fn).toBeCalled();
});

test('Trigger graceful exit', () => {
const processExit = vi.spyOn(process, 'exit').mockImplementation(() => {});
graceful(EMPTY_STRING_INPUT);
expect(processExit).toHaveBeenCalled();
});
});

0 comments on commit 5ffcabc

Please sign in to comment.