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