UNPKG

loqatevars

Version:

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

25 lines (20 loc) 784 B
// Mock globby to avoid ESM loading issues jest.mock('globby'); const { findMatchingFiles } = require('../lib/utils'); const fs = require('fs-extra'); const path = require('path'); const os = require('os'); describe('findMatchingFiles with single JS file', () => { let tempDir; beforeAll(() => { tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'single-match-')); // create isolated temp directory fs.writeFileSync(path.join(tempDir, 'one.js'), 'const demo = 123;'); // create file with const to be flagged }); afterAll(() => { fs.removeSync(tempDir); // clean up temporary directory }); test('should report exactly one matching file', async () => { const result = await findMatchingFiles(tempDir, []); expect(result).toEqual(['one.js']); }); });