0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/modules/manager/batect-wrapper/extract.spec.ts
Michael Kriese b4319928f1
refactor: strict manager tests (#16155)
* refactor: strict manager tests

* chore: revert changes

* Update lib/modules/manager/gradle/extract.spec.ts
2022-06-20 17:05:39 +02:00

46 lines
1.6 KiB
TypeScript

import { Fixtures } from '../../../../test/fixtures';
import { GithubReleasesDatasource } from '../../datasource/github-releases';
import { id as semverVersioning } from '../../versioning/semver';
import type { PackageDependency } from '../types';
import { extractPackageFile } from '.';
describe('modules/manager/batect-wrapper/extract', () => {
describe('extractPackageFile()', () => {
it('returns null for empty wrapper file', () => {
expect(extractPackageFile('')).toBeNull();
});
it('returns null for file without version information', () => {
expect(extractPackageFile('nothing here')).toBeNull();
});
it('extracts the current version from a valid wrapper script', () => {
const res = extractPackageFile(Fixtures.get('valid-wrapper'));
const expectedDependency: PackageDependency = {
depName: 'batect/batect',
commitMessageTopic: 'Batect',
currentValue: '0.60.1',
datasource: GithubReleasesDatasource.id,
versioning: semverVersioning,
};
expect(res).toEqual({ deps: [expectedDependency] });
});
it('returns the first version from a wrapper script with multiple versions', () => {
const res = extractPackageFile(Fixtures.get('malformed-wrapper'));
const expectedDependency: PackageDependency = {
depName: 'batect/batect',
commitMessageTopic: 'Batect',
currentValue: '0.60.1',
datasource: GithubReleasesDatasource.id,
versioning: semverVersioning,
};
expect(res).toEqual({ deps: [expectedDependency] });
});
});
});