mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
9caf45ed43
Co-authored-by: Rhys Arkins <rhys@arkins.net>
42 lines
1.4 KiB
TypeScript
42 lines
1.4 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'}
|
|
`('("$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();
|
|
});
|
|
});
|
|
});
|