diff --git a/src/validatePrTitle.test.js b/src/validatePrTitle.test.js index ee5994bc..2ac78d6c 100644 --- a/src/validatePrTitle.test.js +++ b/src/validatePrTitle.test.js @@ -42,6 +42,56 @@ it('throws for PR titles with an unknown type', async () => { describe('regex types', () => { const headerPattern = /^([\w-]*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$/; + it('works with the suggested header pattern and correspondence', async () => { + await validatePrTitle('fix(deps): delay for tagging lambda', { + headerPattern: '^(\\w*)(?:\\(([\\w$.\\-*/ ]*)\\))?: (.*)$', + headerPatternCorrespondence: ['type', 'scope', 'subject'], + types: [ + 'feat', + 'fix', + 'docs', + 'style', + 'refactor', + 'perf', + 'test', + 'build', + 'ci', + 'chore', + 'revert', + 'release' + ], + scopes: ['main', 'deps', 'except', 'scp'], + requireScope: false, + subjectPattern: '^(?![A-Z]).+$', + subjectPatternError: + 'The subject "{subject}" found in the pull request title "{title}"\ndidn\'t match the configured pattern. Please ensure that the subject\ndoesn\'t start with an uppercase character.', + ignoreLabels: ['bot', 'ignore-semantic-pull-request'] + }); + }); + + it('works with the suggested header pattern and correspondence 2', async () => { + await validatePrTitle('feat(webapp): location distance in profile', { + scopes: [ + 'backend', + 'webapp', + 'frontend', + 'maintenance', + 'database', + 'docu', + 'docker', + 'release', + 'workflow', + 'other' + ], + requireScope: true, + subjectPattern: '^(?![A-Z]).+$', + subjectPatternError: + 'The subject "{subject}" found in the pull request title "{title}"\ndidn\'t match the configured pattern. Please ensure that the subject\ndoesn\'t start with an uppercase character.', + headerPattern: '^(\\w*)(?:\\(([\\w$.\\-*/ ]*)\\))?: (.*)$', + headerPatternCorrespondence: ['type', 'scope', 'subject'] + }); + }); + it('allows a regex matching type', async () => { await validatePrTitle('JIRA-123: Bar', { types: ['JIRA-\\d+'],