Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/validatePrTitle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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+'],
Expand Down