renovate/lib/util/common.spec.ts
Hilário Coelho 8cc08e0660
fix(azure): go-import meta header support for Azure DevOps (#22664)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-06-11 16:58:46 +00:00

44 lines
1.7 KiB
TypeScript

import { detectPlatform } from './common';
import * as hostRules from './host-rules';
describe('util/common', () => {
beforeEach(() => hostRules.clear());
describe('detectPlatform', () => {
it.each`
url | hostType
${'some-invalid@url:::'} | ${null}
${'https://enterprise.example.com/chalk/chalk'} | ${null}
${'https://github.com/semantic-release/gitlab'} | ${'github'}
${'https://github-enterprise.example.com/chalk/chalk'} | ${'github'}
${'https://gitlab.com/chalk/chalk'} | ${'gitlab'}
${'https://gitlab-enterprise.example.com/chalk/chalk'} | ${'gitlab'}
${'https://dev.azure.com/my-organization/my-project/_git/my-repo.git'} | ${'azure'}
${'https://myorg.visualstudio.com/my-project/_git/my-repo.git'} | ${'azure'}
`('("$url") === $hostType', ({ url, hostType }) => {
expect(detectPlatform(url)).toBe(hostType);
});
it('uses host rules', () => {
hostRules.add({
hostType: 'gitlab-changelog',
matchHost: 'gl.example.com',
});
hostRules.add({
hostType: 'github-changelog',
matchHost: 'gh.example.com',
});
hostRules.add({
hostType: 'gitea',
matchHost: 'gt.example.com',
});
expect(detectPlatform('https://gl.example.com/chalk/chalk')).toBe(
'gitlab'
);
expect(detectPlatform('https://gh.example.com/chalk/chalk')).toBe(
'github'
);
expect(detectPlatform('https://gt.example.com/chalk/chalk')).toBeNull();
});
});
});