0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-12 22:29:06 +00:00
renovatebot_renovate/lib/modules/datasource/ruby-version/index.spec.ts
2023-11-07 15:50:29 +00:00

44 lines
1.2 KiB
TypeScript

import { getPkgReleases } from '..';
import { Fixtures } from '../../../../test/fixtures';
import * as httpMock from '../../../../test/http-mock';
import { RubyVersionDatasource } from '.';
const datasource = RubyVersionDatasource.id;
describe('modules/datasource/ruby-version/index', () => {
describe('getReleases', () => {
it('parses real data', async () => {
httpMock
.scope('https://www.ruby-lang.org')
.get('/en/downloads/releases/')
.reply(200, Fixtures.get('releases.html'));
const res = await getPkgReleases({
datasource,
packageName: 'ruby',
});
expect(res).toMatchSnapshot();
});
it('returns null for empty result', async () => {
httpMock
.scope('https://www.ruby-lang.org')
.get('/en/downloads/releases/')
.reply(200, {});
const res = await getPkgReleases({
datasource,
packageName: 'ruby',
});
expect(res).toBeNull();
});
it('throws for 404', async () => {
httpMock
.scope('https://www.ruby-lang.org')
.get('/en/downloads/releases/')
.reply(404);
await expect(
getPkgReleases({ datasource, packageName: 'ruby' }),
).rejects.toThrow();
});
});
});