mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
const datasource = require('../../lib/datasource');
|
|
const ghGot = require('../../lib/platform/github/gh-got-wrapper');
|
|
|
|
jest.mock('../../lib/platform/github/gh-got-wrapper');
|
|
jest.mock('got');
|
|
|
|
describe('datasource/github', () => {
|
|
describe('getPkgReleases', () => {
|
|
it('returns cleaned tags', async () => {
|
|
const body = [
|
|
{ name: 'a' },
|
|
{ name: 'v' },
|
|
{ name: '1.0.0' },
|
|
{ name: 'v1.1.0' },
|
|
];
|
|
ghGot.mockReturnValueOnce({ headers: {}, body });
|
|
const res = await datasource.getPkgReleases(
|
|
'pkg:github/some/dep?sanitize=true'
|
|
);
|
|
expect(res).toMatchSnapshot();
|
|
expect(res.releases).toHaveLength(2);
|
|
expect(
|
|
res.releases.find(release => release.version === '1.1.0')
|
|
).toBeDefined();
|
|
});
|
|
it('returns releases', async () => {
|
|
const body = [
|
|
{ tag_name: 'a' },
|
|
{ tag_name: 'v' },
|
|
{ tag_name: '1.0.0' },
|
|
{ tag_name: 'v1.1.0' },
|
|
];
|
|
ghGot.mockReturnValueOnce({ headers: {}, body });
|
|
const res = await datasource.getPkgReleases(
|
|
'pkg:github/some/dep?ref=release'
|
|
);
|
|
expect(res).toMatchSnapshot();
|
|
expect(res.releases).toHaveLength(2);
|
|
expect(
|
|
res.releases.find(release => release.version === 'v1.1.0')
|
|
).toBeDefined();
|
|
});
|
|
it('returns null for invalid ref', async () => {
|
|
expect(
|
|
await datasource.getPkgReleases('pkg:github/some/dep?ref=invalid')
|
|
).toBeNull();
|
|
});
|
|
});
|
|
});
|