renovate/lib/modules/datasource/ruby-version/index.spec.ts
2022-04-12 14:49:49 +00:00

42 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,
depName: 'ruby',
});
expect(res).toMatchSnapshot();
});
it('throws for empty result', async () => {
httpMock
.scope('https://www.ruby-lang.org')
.get('/en/downloads/releases/')
.reply(200, {});
await expect(
getPkgReleases({ datasource, depName: 'ruby' })
).rejects.toThrow();
});
it('throws for 404', async () => {
httpMock
.scope('https://www.ruby-lang.org')
.get('/en/downloads/releases/')
.reply(404);
await expect(
getPkgReleases({ datasource, depName: 'ruby' })
).rejects.toThrow();
});
});
});