0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-05-12 23:51:55 +00:00
renovatebot_renovate/lib/modules/manager/npm/detect.spec.ts
2025-03-13 17:52:09 +00:00

30 lines
854 B
TypeScript

import { detectGlobalConfig } from '.';
import { fs } from '~test/util';
vi.mock('../../../util/fs');
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({});
});
});
});