UNPKG

loqatevars

Version:

Locate JavaScript files with 'const' or 'process.env' usage in LLM-generated codebases

31 lines (25 loc) 870 B
const { main } = require('../cli.js'); const utils = require('../lib/utils.js'); jest.mock('../lib/utils.js'); describe('CLI invalid command', () => { 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('prints help and does not execute scan for unknown command', async () => { process.argv = ['node', 'cli.js', 'unknown']; await main(); expect(utils.findMatchingFiles).not.toHaveBeenCalled(); expect(logSpy).toHaveBeenCalled(); const output = logSpy.mock.calls.map(c => c.join(' ')).join('\n'); expect(output).toMatch(/Unknown command: unknown/); expect(output).toMatch(/Commands:/); }); });