Files
renovate/lib/modules/manager/npm/detect.spec.ts
2026-02-06 13:40:01 +00:00

31 lines
875 B
TypeScript

import { fs } from '~test/util.ts';
import { detectGlobalConfig } from './index.ts';
vi.mock('../../../util/fs/index.ts');
describe('modules/manager/npm/detect', () => {
describe('.detectGlobalConfig()', () => {
it('detects .npmrc in home directory', async () => {
fs.readSystemFile.mockResolvedValueOnce(
'registry=https://registry.npmjs.org\n',
);
const res = await detectGlobalConfig();
expect(res).toMatchInlineSnapshot(`
{
"npmrc": "registry=https://registry.npmjs.org
",
"npmrcMerge": true,
}
`);
expect(res.npmrc).toBeDefined();
expect(res.npmrcMerge).toBe(true);
});
it('handles no .npmrc', async () => {
fs.readSystemFile.mockRejectedValueOnce('error');
const res = await detectGlobalConfig();
expect(res).toEqual({});
});
});
});