renovate/lib/manager/npm/extract/yarn.spec.ts
2020-07-03 16:47:00 +02:00

25 lines
833 B
TypeScript

import { readFileSync } from 'fs';
import { fs } from '../../../../test/util';
import { getYarnLock } from './yarn';
jest.mock('../../../util/fs');
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);
});
});
});