mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 18:19:51 +00:00
05e1271376
Enables the vitest/prefer-expect-resolves oxlint rule and applies its autofix across the spec suite.
91 lines
2.6 KiB
TypeScript
91 lines
2.6 KiB
TypeScript
import * as httpMock from '~test/http-mock.ts';
|
|
import { getPkgReleases } from '../index.ts';
|
|
import { GitlabReleasesDatasource } from './index.ts';
|
|
|
|
describe('modules/datasource/gitlab-releases/index', () => {
|
|
describe('getReleases', () => {
|
|
const body = [
|
|
{
|
|
tag_name: 'v1.0.0',
|
|
released_at: '2021-01-01T00:00:00.000Z',
|
|
},
|
|
{
|
|
tag_name: 'v1.1.0',
|
|
released_at: '2021-03-01T00:00:00.000Z',
|
|
},
|
|
];
|
|
|
|
it('returns releases from custom registry', async () => {
|
|
httpMock
|
|
.scope('https://gitlab.company.com')
|
|
.get('/api/v4/projects/some%2Fdep2/releases')
|
|
.reply(200, body);
|
|
const res = await getPkgReleases({
|
|
datasource: GitlabReleasesDatasource.id,
|
|
registryUrls: ['https://gitlab.company.com'],
|
|
packageName: 'some/dep2',
|
|
});
|
|
expect(res).toEqual({
|
|
registryUrl: 'https://gitlab.company.com',
|
|
releases: [
|
|
{
|
|
gitRef: 'v1.0.0',
|
|
registryUrl: 'https://gitlab.company.com',
|
|
releaseTimestamp: '2021-01-01T00:00:00.000Z',
|
|
version: 'v1.0.0',
|
|
},
|
|
{
|
|
gitRef: 'v1.1.0',
|
|
registryUrl: 'https://gitlab.company.com',
|
|
releaseTimestamp: '2021-03-01T00:00:00.000Z',
|
|
version: 'v1.1.0',
|
|
},
|
|
],
|
|
sourceUrl: 'https://gitlab.company.com/some/dep2',
|
|
});
|
|
});
|
|
|
|
it('returns releases from default registry', async () => {
|
|
httpMock
|
|
.scope('https://gitlab.com')
|
|
.get('/api/v4/projects/some%2Fdep2/releases')
|
|
.reply(200, body);
|
|
const res = await getPkgReleases({
|
|
datasource: GitlabReleasesDatasource.id,
|
|
packageName: 'some/dep2',
|
|
});
|
|
expect(res).toEqual({
|
|
registryUrl: 'https://gitlab.com',
|
|
releases: [
|
|
{
|
|
gitRef: 'v1.0.0',
|
|
registryUrl: 'https://gitlab.com',
|
|
releaseTimestamp: '2021-01-01T00:00:00.000Z',
|
|
version: 'v1.0.0',
|
|
},
|
|
{
|
|
gitRef: 'v1.1.0',
|
|
registryUrl: 'https://gitlab.com',
|
|
releaseTimestamp: '2021-03-01T00:00:00.000Z',
|
|
version: 'v1.1.0',
|
|
},
|
|
],
|
|
sourceUrl: 'https://gitlab.com/some/dep2',
|
|
});
|
|
});
|
|
|
|
it('return null if not found', async () => {
|
|
httpMock
|
|
.scope('https://gitlab.com')
|
|
.get('/api/v4/projects/some%2Fdep2/releases')
|
|
.reply(404);
|
|
await expect(
|
|
getPkgReleases({
|
|
datasource: GitlabReleasesDatasource.id,
|
|
packageName: 'some/dep2',
|
|
}),
|
|
).resolves.toBeNull();
|
|
});
|
|
});
|
|
});
|