0
0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-03 02:39:06 +00:00
renovatebot_renovate/lib/config/validation-helpers/regex-glob-matchers.spec.ts
RahulGautamSingh 265e6285c7
feat(config/validation): validate options which support regex/glob matching (#28693)
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-05-05 07:45:58 +00:00

34 lines
885 B
TypeScript

import { check } from './regex-glob-matchers';
describe('config/validation-helpers/regex-glob-matchers', () => {
it('should error for multiple match alls', () => {
const res = check({
val: ['*', '**'],
currentPath: 'hostRules[0].allowedHeaders',
});
expect(res).toHaveLength(1);
});
it('should error for invalid regex', () => {
const res = check({
val: ['[', '/[/', '/.*[/'],
currentPath: 'hostRules[0].allowedHeaders',
});
expect(res).toHaveLength(2);
});
it('should error for non-strings', () => {
const res = check({
val: ['*', 2],
currentPath: 'hostRules[0].allowedHeaders',
});
expect(res).toMatchObject([
{
message:
'hostRules[0].allowedHeaders: should be an array of strings. You have included object.',
topic: 'Configuration Error',
},
]);
});
});