mirror of
https://github.com/yamadashy/repomix.git
synced 2025-06-11 00:25:54 +03:00
add test
This commit is contained in:
committed by
Kazuki Yamada
parent
9091bf0a9b
commit
97d550e946
@@ -140,7 +140,7 @@ export const run = async () => {
|
||||
await program.parseAsync(process.argv);
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
process.exit(1)
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
import { program } from 'commander';
|
||||
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
import * as defaultAction from '../../src/cli/actions/defaultAction.js';
|
||||
import * as initAction from '../../src/cli/actions/initAction.js';
|
||||
import * as remoteAction from '../../src/cli/actions/remoteAction.js';
|
||||
@@ -156,11 +156,16 @@ describe('cliRun', () => {
|
||||
|
||||
test('should call process.exit(1) on error', async () => {
|
||||
const exitSpy = vi.spyOn(process, 'exit').mockImplementationOnce(() => undefined as never);
|
||||
const parseSpy = vi.spyOn(program, 'description').mockImplementationOnce(() => { throw Error() });
|
||||
const parseSpy = vi.spyOn(program, 'description').mockImplementationOnce(() => {
|
||||
throw Error();
|
||||
});
|
||||
const handleErrorSpy = vi.spyOn(logger, 'error');
|
||||
await expect(run()).resolves.not.toThrow();
|
||||
expect(exitSpy).toHaveBeenCalledWith(1)
|
||||
expect(exitSpy).toHaveBeenCalledWith(1);
|
||||
expect(handleErrorSpy).toHaveBeenCalled();
|
||||
exitSpy.mockReset();
|
||||
parseSpy.mockReset();
|
||||
handleErrorSpy.mockReset();
|
||||
});
|
||||
|
||||
describe('executeAction', () => {
|
||||
|
||||
Reference in New Issue
Block a user