2018-06-08 08:49:08 +00:00
|
|
|
const datasource = require('../../lib/datasource');
|
2018-12-10 05:34:39 +00:00
|
|
|
const npmDatasource = require('../../lib/datasource/npm');
|
2018-06-08 08:49:08 +00:00
|
|
|
|
2018-07-20 07:09:01 +00:00
|
|
|
jest.mock('../../lib/datasource/docker');
|
2018-12-10 05:34:39 +00:00
|
|
|
jest.mock('../../lib/datasource/npm');
|
2018-07-20 07:09:01 +00:00
|
|
|
|
2018-06-08 08:49:08 +00:00
|
|
|
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();
|
|
|
|
});
|
2018-06-08 08:49:08 +00:00
|
|
|
it('returns null for invalid purl', async () => {
|
2019-01-28 05:40:37 +00:00
|
|
|
expect(
|
|
|
|
await datasource.getPkgReleases({ purl: 'pkggithub/some/dep' })
|
|
|
|
).toBeNull();
|
2018-06-08 08:49:08 +00:00
|
|
|
});
|
2018-07-20 07:09:01 +00:00
|
|
|
it('returns getDigest', async () => {
|
2018-07-21 08:47:29 +00:00
|
|
|
expect(
|
|
|
|
await datasource.getDigest({ purl: 'pkg:docker/node' })
|
|
|
|
).toBeUndefined();
|
2018-07-20 07:09:01 +00:00
|
|
|
});
|
2018-12-10 05:34:39 +00:00
|
|
|
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',
|
|
|
|
});
|
2018-12-10 05:34:39 +00:00
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.changelogUrl).toBeDefined();
|
|
|
|
expect(res.sourceUrl).toBeDefined();
|
|
|
|
});
|
2018-12-10 05:49:15 +00:00
|
|
|
it('adds sourceUrl', async () => {
|
|
|
|
npmDatasource.getPkgReleases.mockReturnValue({});
|
2019-01-28 05:40:37 +00:00
|
|
|
const res = await datasource.getPkgReleases({ purl: 'pkg:npm/node' });
|
2018-12-10 05:49:15 +00:00
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.sourceUrl).toBeDefined();
|
|
|
|
});
|
2018-06-08 08:49:08 +00:00
|
|
|
});
|