renovate/test/datasource/index.spec.js

42 lines
1.4 KiB
JavaScript
Raw Normal View History

const datasource = require('../../lib/datasource');
const npmDatasource = require('../../lib/datasource/npm');
jest.mock('../../lib/datasource/docker');
jest.mock('../../lib/datasource/npm');
describe('datasource/index', () => {
2019-01-29 17:14:06 +00:00
it('returns if digests are supported', async () => {
expect(await datasource.supportsDigests('pkg:github/some/dep')).toBe(true);
});
it('returns null for unknown datasource', async () => {
expect(
await datasource.getPkgReleases({ purl: 'pkg:gitbucket/some/dep' })
).toBeNull();
});
it('returns null for invalid purl', async () => {
2019-01-28 05:40:37 +00:00
expect(
await datasource.getPkgReleases({ purl: 'pkggithub/some/dep' })
).toBeNull();
});
it('returns getDigest', async () => {
expect(
await datasource.getDigest({ purl: 'pkg:docker/node' })
).toBeUndefined();
});
it('adds changelogUrl', async () => {
npmDatasource.getPkgReleases.mockReturnValue({});
2019-01-28 05:40:37 +00:00
const res = await datasource.getPkgReleases({
purl: 'pkg:npm/react-native',
});
expect(res).toMatchSnapshot();
expect(res.changelogUrl).toBeDefined();
expect(res.sourceUrl).toBeDefined();
});
it('adds sourceUrl', async () => {
npmDatasource.getPkgReleases.mockReturnValue({});
2019-01-28 05:40:37 +00:00
const res = await datasource.getPkgReleases({ purl: 'pkg:npm/node' });
expect(res).toMatchSnapshot();
expect(res.sourceUrl).toBeDefined();
});
});