loqatevars
Version:
Locate JavaScript files with 'const' or 'process.env' usage in LLM-generated codebases
35 lines (28 loc) • 1.14 kB
JavaScript
const { main } = require('../cli.js');
const { findMatchingFiles } = require('../lib/utils.js');
jest.mock('../lib/utils.js');
describe('CLI multiple option parsing', () => {
let logSpy;
let exitSpy;
beforeEach(() => {
logSpy = jest.spyOn(console, 'log').mockImplementation();
exitSpy = jest.spyOn(process, 'exit').mockImplementation();
});
afterEach(() => {
logSpy.mockRestore();
exitSpy.mockRestore();
jest.clearAllMocks();
});
test('multiple --ignore options combine correctly', async () => {
process.argv = ['node', 'cli.js', 'scan', './src', '--ignore', 'one.js', '--ignore', 'two.js'];
findMatchingFiles.mockResolvedValue([]);
await main();
expect(findMatchingFiles).toHaveBeenCalledWith('./src', ['one.js', 'two.js'], ['.js']);
});
test('multiple --extensions options combine correctly', async () => {
process.argv = ['node', 'cli.js', 'scan', './src', '--extensions', '.js', '--extensions', '.ts'];
findMatchingFiles.mockResolvedValue([]);
await main();
expect(findMatchingFiles).toHaveBeenCalledWith('./src', ['**/localVars.js'], ['.js', '.ts']);
});
});