renovate/lib/modules/datasource/ruby-version/index.spec.ts
Rhys Arkins dca3418bbd refactor: lib/modules (#14488)
Moves datasource, manager, platform and versioning code from lib/ into new lib/modules/

BREAKING CHANGE: External tools must update paths to datasource, manager, platform and versioning
2022-03-04 09:04:02 +01:00

44 lines
1.4 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();
expect(httpMock.getTrace()).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();
expect(httpMock.getTrace()).toMatchSnapshot();
});
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();
expect(httpMock.getTrace()).toMatchSnapshot();
});
});
});