renovate/lib/manager/npm/extract/yarn.spec.ts

26 lines
833 B
TypeScript
Raw Normal View History

import { readFileSync } from 'fs';
import { fs } from '../../../../test/util';
2020-05-01 16:03:48 +00:00
import { getYarnLock } from './yarn';
jest.mock('../../../util/fs');
2019-07-17 08:14:56 +00:00
describe('manager/npm/extract/yarn', () => {
describe('.getYarnLock()', () => {
it('returns empty if exception parsing', async () => {
fs.readLocalFile.mockResolvedValueOnce('abcd');
const res = await getYarnLock('package.json');
expect(Object.keys(res)).toHaveLength(0);
});
it('extracts', async () => {
const plocktest1Lock = readFileSync(
'lib/manager/npm/__fixtures__/plocktest1/yarn.lock',
'utf8'
);
fs.readLocalFile.mockResolvedValueOnce(plocktest1Lock);
const res = await getYarnLock('package.json');
expect(res).toMatchSnapshot();
expect(Object.keys(res)).toHaveLength(7);
});
});
});